attempt-4 gated every bare-type-reference site for VISIBILITY via a boolean
leak-check that only caught not-visible and DROPPED the ambiguous outcome, so two
DIRECT flat same-name type authors (the 0755/0105 ambiguity case) fell through to
a global findByName / struct_template_map pick at the non-leaf sites.
Unified author-outcome fix (one path, every site consumes it):
- flatTypeAuthorCount: ≥2 distinct flat authors that do NOT all collapse onto one
shared TypeId are now `.ambiguous` even when none carries a concrete TypeId yet —
two same-name GENERIC TEMPLATES (template name registered in no findByName slot)
are a genuine collision, exactly like two registered structs. Identical-target
authors (diamond import / two aliases onto the same target) still collapse to
`.one`, so all valid cases stay byte-identical.
- headTypeGate: the complete source-aware author outcome (.proceed / .resolved /
.ambiguous / .not_visible) for an unqualified bare TYPE head, emitting the loud
ambiguity diagnostic (consistent with the leaf / 0755) or the not-visible
diagnostic. headTypeLeak is now its poison-vs-proceed projection, so every head /
instantiation / alias-decl / match site poisons on ambiguity with the right
message. Reflection / type-arg and array/vector-literal identifier heads consume
`.resolved` to use the source-keyed TypeId, never a global findByName pick.
Regression examples/0767: size_of(Thing) / Nums.[1,2] / Box(s64) / t:Type=Thing /
case Thing: with two direct flat same-name authors each emit the ambiguity
diagnostic, exit 1 (fail-before on bb8f7dc: exit 0 / cascade). 0763/0764/0765/0766
/0755/0706/0544/0105 + FFI byte-identical. README: bare-type ambiguity is enforced
at every reference site.
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
// Bare-TYPE references are NON-transitive AND ambiguity-checked at every site,
|
|
// not just the nominal leaf annotation (0755). `main` flat-imports two modules
|
|
// that each author a same-name `Thing` / `Box` / `Nums` and authors none itself,
|
|
// so EACH of the following bare forms is a genuine collision the source cannot
|
|
// disambiguate — and each must emit the LOUD "type ... is ambiguous" diagnostic
|
|
// (consistent with the leaf, 0755) and poison the result, NEVER silently pick a
|
|
// global `findByName` / `struct_template_map` author:
|
|
//
|
|
// - reflection / type-arg slot `size_of(Thing)`
|
|
// - typed array/vector-literal `Nums.[1, 2]`
|
|
// - parameterized generic head `Box(s64)`
|
|
// - type-as-value `t : Type = Thing`
|
|
// - type-category match arm `case Thing:`
|
|
//
|
|
// Regression (Phase E4 attempt-5): before the bare-type gate carried the full
|
|
// source-aware author outcome, these non-leaf sites used a boolean leak-check
|
|
// that dropped the AMBIGUOUS outcome — two direct flat same-name authors fell
|
|
// through to a global pick (exit 0 / cascade) instead of the loud diagnostic.
|
|
|
|
#import "modules/std.sx";
|
|
#import "0767-modules-ambiguous-bare-type-forms/a.sx";
|
|
#import "0767-modules-ambiguous-bare-type-forms/b.sx";
|
|
|
|
describe :: ($T: Type) -> s32 {
|
|
r := if T == {
|
|
case Thing: 1;
|
|
else: 0;
|
|
}
|
|
r
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
sz := size_of(Thing);
|
|
xs := Nums.[1, 2];
|
|
x : Box(s64) = .{ v = 3 };
|
|
t : Type = Thing;
|
|
d := describe(s64);
|
|
0
|
|
}
|