lang: generic struct head aliases bind the template (fix 0120) — alias-follow from each author's source in head selection; loud unknown-type on the .call type tail

BoxAlias :: Box; / Box :: r.Box; now resolve instantiation, methods,
annotations, and chains through the aliased template, and re-export one
flat-import level as ordinary own decls (the facade shape the std.sx
restructure needs). selectGenericStructHead consults aliasedStructTemplate
(nominal.zig) before the global template map — own-wins/single-flat alias
author, each hop pinned to the alias author's source, ns.X RHS through
namespaceAliasVerdictFrom, depth-capped. resolveTypeCallWithBindings'
silent .unresolved tail (panicked in LLVM emission) now diagnoses
"unknown type". Also aligns the stale pre-existing calls.test.zig UFCS
plan test with the opt-in model (a47ea14). Regression: examples/0211
(+rich/+facade). Gates: zig build test 426/426, suite 587/587.
This commit is contained in:
agra
2026-06-11 18:09:01 +03:00
parent 51194a26d8
commit f2db8ecc53
13 changed files with 382 additions and 5 deletions

View File

@@ -483,6 +483,25 @@ Carried aliases follow declaration rules: an own declaration shadows a carried
alias, two flat imports carrying the same alias make its use ambiguous, and
carry does not chain through a second flat hop.
**Re-exporting through alias declarations.** Since visibility never chains,
a facade re-exports another module's members as its OWN declarations —
ordinary aliases, which its direct flat importers then see bare. This works
for functions, plain types, and generic struct heads alike (the generic
alias binds the same template, so instantiation and methods resolve
through it):
```sx
// facade.sx
r :: #import "rich.sx";
helper :: r.helper; // fn re-export
Thing :: r.Thing; // struct re-export
Box :: r.Box; // generic head re-export — same template
// consumer.sx
#import "facade.sx";
b := Box(s64).{ item = 3 }; // rich.sx's Box, via the facade
```
### Implicit Context
Every program gets an implicit `context` with a default allocator: