E4 non-transitive type rule had two generic-head author-selection holes: #1 A BARE generic struct head / alias with a single bare-VISIBLE author still instantiated a NON-visible 2-flat-hop same-name template, because the `.unregistered` gate arm fell through to the global last-wins `struct_template_map` winner. Add `bareVisibleStructTemplate`: after the visibility gate passes, select the source-keyed template authored by the single bare-visible author (own-wins, else the one 1-hop flat author) and instantiate THAT instead of the global map's last-wins entry. Null (→ the global map, byte-identical) when the visible author IS the canonical one (the common single-author case) or the picture isn't a clean single author. Applied at every bare generic-struct head/alias site (annotation `.call` / `.parameterized_type_expr`, alias-registration `.call` / `.parameterized_type_expr`, array-literal head). #2 A QUALIFIED head `a.Box(..)` whose namespace `a` authors no member `Box` silently fell back to the bare global template, instantiating an unrelated module's `Box`. Add `qualifiedMemberMissing`: a qualified head whose known namespace lacks the member now emits "namespace 'a' has no member 'Box'" and poisons with `.unresolved`; a qualified head NEVER reaches the bare global map. Regressions: 0774 (bare head + bare alias, 2-hop same-name → size=8 alias=8, fail-before 16 16); 0775 (qualified missing member → diagnostic + exit 1, fail-before size=16 exit 0).
29 lines
1.3 KiB
Plaintext
29 lines
1.3 KiB
Plaintext
// A BARE generic struct head (`Box(s64)`) and a BARE generic alias
|
|
// (`ABox :: Box(s64)`) must instantiate the template authored by the single
|
|
// bare-VISIBLE author — this file's own author or a DIRECT (1-hop) flat import —
|
|
// NOT the global last-wins `struct_template_map`, which a NON-visible 2-flat-hop
|
|
// same-name template can win.
|
|
//
|
|
// `b.sx` declares a one-field `Box($T)` (size 8) and itself flat-imports `c.sx`,
|
|
// which declares a two-field `Box($T)` (size 16). This file flat-imports ONLY
|
|
// `b.sx`, so `b.Box` is one flat hop away (visible) and `c.Box` is two hops away
|
|
// (NOT bare-visible, mirrors 0764/0706). The bare head `Box(s64)` and the bare
|
|
// alias `ABox :: Box(s64)` must both select `b.Box` (size 8).
|
|
//
|
|
// Regression (Phase E4 finding #1): before the bare head/alias consulted the
|
|
// source-keyed visible author, both fell through the `.unregistered` gate arm to
|
|
// the global last-wins template and instantiated the non-visible `c.Box`
|
|
// (size 16). Fail-before printed `size=16 alias=16`.
|
|
|
|
#import "modules/std.sx";
|
|
#import "0774-modules-bare-generic-head-visible-author/b.sx";
|
|
|
|
ABox :: Box(s64);
|
|
|
|
main :: () -> s32 {
|
|
x : Box(s64) = .{ x = 1 };
|
|
a : ABox = .{ x = 2 };
|
|
print("size={} alias={} x={} a={}\n", size_of(Box(s64)), size_of(ABox), x.x, a.x);
|
|
0
|
|
}
|