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:
19
specs.md
19
specs.md
@@ -1251,6 +1251,25 @@ A name bound to an existing type.
|
||||
SOME_TYPE :: f64;
|
||||
```
|
||||
|
||||
A generic struct HEAD can be aliased too — the alias binds to the same
|
||||
template, so instantiation, methods, annotations, and alias chains resolve
|
||||
through it:
|
||||
|
||||
```sx
|
||||
Box :: struct ($T: Type) { item: T; }
|
||||
BoxAlias :: Box; // same template
|
||||
b := BoxAlias(s64).{ item = 3 };
|
||||
b2 : BoxAlias(string) = .{ item = "x" }; // annotation head too
|
||||
```
|
||||
|
||||
The RHS may be a namespace member (`Box :: r.Box;`) — the alias is an
|
||||
ordinary OWN declaration of the aliasing file, so it is visible to that
|
||||
file's direct flat importers like any other declaration (this is how a
|
||||
facade re-exports another module's generic struct). Each hop of an alias
|
||||
chain resolves with the visibility of the file that declares THAT hop,
|
||||
not the use site's. Not yet supported: a qualified head whose namespace
|
||||
member is itself an alias (`ns.BoxAlias(..)`).
|
||||
|
||||
### Generic Functions (Monomorphization)
|
||||
Functions can be parameterized over types using `$T` syntax. The `$` prefix introduces a type parameter; subsequent uses of the name reference it.
|
||||
```sx
|
||||
|
||||
Reference in New Issue
Block a user