R4: a type alias is a `const_decl`, not a named-type decl, so the bare-TYPE
visibility gate ignored aliases — a namespaced-only alias leaked bare (silent
empty-struct stub, no diagnostic) and a flat-visible alias was poisoned by an
invisible same-name named type. Unify both type-author kinds (named type AND
alias) behind one per-module predicate `moduleTypeAuthor`, returning the author
KIND so resolution is decoupled from `findByName` timing (a forward/self
reference like `next: *ArenaChunk`, unregistered mid-registration, is still
recognised as an author and falls to the legacy stub instead of a false
"not visible"). The leak detector `nameAuthoredAsTypeAnywhere` now also scans
`type_aliases_by_source`. Single source of truth across named types, top-level
aliases, and parameterized/type-fn aliases — leak side and false-rejection side.
Behavior-preserving for single-author names (full suite byte-identical, paths
normalized). Generic / parameterized-protocol / Vector / type-function heads
stay legacy (0210). Block-local `Name :: <type>` remains a value const under the
reserved-name duality (pre-existing; the gate handles it safely, no leak).
Regressions: 0747 (ns-only alias bare -> not visible), 0748 (flat-visible alias
not poisoned by ns-only same-name struct). Both fail-before on 4bd57c8 /
pass-after here.
19 lines
887 B
Plaintext
19 lines
887 B
Plaintext
// A flat-visible (here own-module) type ALIAS must resolve even when a
|
|
// namespaced-only import authors a same-name NAMED type — the alias↔named-type
|
|
// analog of 0745/0746 (R4, FALSE-REJECTION direction). `dep.sx` is namespaced
|
|
// (`ns :: #import`) and authors a top-level `Secret` STRUCT; `main` authors its
|
|
// OWN top-level alias `Secret :: s32`. A bare `Secret` must resolve to MAIN's
|
|
// alias (`s32`), NOT be poisoned by the invisible same-name struct: the alias is
|
|
// the only flat-visible TYPE author. Before the fix the leaf saw the global
|
|
// `findByName` struct and, finding no NAMED-type author in `main` (an alias is a
|
|
// `const_decl`, not a named type), wrongly rejected the bare reference as "not
|
|
// visible". Regression (issue R4).
|
|
ns :: #import "0748-modules-flat-alias-shadows-ns-only-type/dep.sx";
|
|
|
|
Secret :: s32;
|
|
|
|
main :: () -> s32 {
|
|
x : Secret = 42;
|
|
x
|
|
}
|