Files
sx/examples/0747-modules-namespaced-only-bare-alias-not-visible.sx
agra daf4bbc862 fix(resolver): treat type aliases as bare-TYPE authors in both gate directions [stdlib E1 attempt-4]
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.
2026-06-07 18:41:01 +03:00

17 lines
941 B
Plaintext

// Bare TYPE-ALIAS visibility under a NAMESPACED-only import — the alias sibling
// of 0743 (bare named type) and 0742 (bare const). A type ALIAS is a `const_decl`
// whose value resolved to a type, so it never registers a `findByName` named-type
// entry; the source-aware leaf must still treat it as a TYPE author (R4). `dep.sx`
// is imported only as `dep :: #import`, so its top-level `Secret :: s32` alias is
// reachable ONLY as `dep.Secret`. A BARE `Secret` in a type position must NOT
// resolve: bare-TYPE visibility joins over the FLAT import edges, and a namespaced
// alias is not a flat edge. Before the fix the ns-only alias was NOT a recognised
// type author, so the bare reference fell to the legacy empty-struct stub with NO
// diagnostic (the value silently came out 0). Regression (issue R4).
dep :: #import "0747-modules-namespaced-only-bare-alias-not-visible/dep.sx";
main :: () -> s32 {
x : Secret = 7;
x
}