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).
24 lines
982 B
Plaintext
24 lines
982 B
Plaintext
// A QUALIFIED generic head `a.Box(s64)` where namespace `a` exists but authors
|
|
// NO member named `Box` must DIAGNOSE the missing member — never silently fall
|
|
// back to the bare last-wins `struct_template_map` and instantiate an unrelated
|
|
// module's same-name `Box`.
|
|
//
|
|
// `a.sx` authors only `Other` (no `Box`); `b.sx` authors a generic `Box($T)`.
|
|
// The qualified reference `a.Box(s64)` must report that `a` has no member `Box`,
|
|
// NOT resolve to `b.Box`.
|
|
//
|
|
// Regression (Phase E4 finding #2): before the qualified head path diagnosed the
|
|
// missing member, `qualifiedStructTemplate` returned null and the code fell
|
|
// through to the bare global template, silently instantiating `b.Box`
|
|
// (`size=16 x=1 y=2`, exit 0).
|
|
|
|
#import "modules/std.sx";
|
|
a :: #import "0775-modules-qualified-generic-missing-member/a.sx";
|
|
b :: #import "0775-modules-qualified-generic-missing-member/b.sx";
|
|
|
|
main :: () -> s32 {
|
|
x : a.Box(s64) = .{ x = 1, y = 2 };
|
|
print("{}\n", x.x);
|
|
0
|
|
}
|