The static-method-call head `Box(s64).make(7)` was the last uncovered bare- generic-head instantiation site: it gated visibility with `headTypeLeak` but then instantiated the global last-wins `struct_template_map` entry and ran the name-keyed `Box.make` from `fn_ast_map`, so a NON-visible 2-flat-hop same-name template (and its method) won. `size_of(Box(s64))` picked the visible `b.Box` (8) while `Box(s64).make(7)` returned a `c.Box`-shaped (16) value. Route the static-method head through the single bare-VISIBLE author for BOTH the instantiated type layout AND the method body: split the existing visible- author selection into `bareVisibleStructDecl` (returns the StructDecl + source; single selection point, `bareVisibleStructTemplate` now delegates to it — no drift) and source-pin the method body via the author's own `sd.methods` (`structMethodFn`) instead of the last-wins `fn_ast_map`. Ambiguity (>1 visible author) is already diagnosed by the pre-existing `headTypeLeak` gate. Exhaustive bare-head instantiation-site audit (all callers reaching `instantiateGenericStruct` / `struct_template_map` for a bare head): .call alias, .parameterized_type_expr alias, resolveType .call, resolveTypeCallWithBindings, resolveParameterizedWithBindings — all already route through the visible-author selection; the static-method head was the only remaining one and is now covered. Regression 0776: bare generic static-method head with a 2-hop same-name template asserts the visible author's layout (xtype=8, x reachable); fail-before xtype=16.
14 lines
462 B
Plaintext
14 lines
462 B
Plaintext
// The NON-visible 2-flat-hop author: a two-field generic `Box` (size 16) with its
|
|
// own `make` (sets a second field). Same template NAME as b's, different layout.
|
|
// It wins the global last-wins `struct_template_map` (and the name-keyed
|
|
// `Box.make`), so the static-method head in a file importing only b.sx must NOT
|
|
// pick it.
|
|
Box :: struct($T: Type) {
|
|
x: T;
|
|
y: T;
|
|
|
|
make :: (value: T) -> Box(T) {
|
|
.{ x = value, y = value + 100 }
|
|
}
|
|
}
|