A block-local type is visible only within the source that declares it. The
global `local_type_names` set was source-insensitive, so an imported generic
template's field (resolved in the template's source context, attempt-4) could
bind a type the CALLER declared block-local — silently compiling an undeclared
imported field instead of diagnosing it.
Key `local_type_names` by declaring source. The bare-TYPE gate now resolves a
local only when the query originates in the local's own source (R2 preserved);
a same-name block-local of a DIFFERENT source routes to the undeclared path so
the leak surfaces (`unknown type '...'`, exit 1) instead of escaping via the
`registered` catch-all that would otherwise resolve the globally-registered
cross-source local.
Regression: examples/0762 — imported `Bad :: struct($T) { x: T; y: LocalOnly; }`
with `LocalOnly` declared only in the caller `main` now errors in lib.sx
(fail-before on 8162170 printed `1 9` exit 0).
10 lines
464 B
Plaintext
10 lines
464 B
Plaintext
// Flat-imported generic struct whose field `y: LocalOnly` names a type that is
|
|
// declared only as a BLOCK-LOCAL in the CALLER (`main`). The template's fields
|
|
// resolve in THIS module's source context (E3 attempt-4), and a block-local type
|
|
// is visible only within its own source, so `LocalOnly` is genuinely undeclared
|
|
// here — the source-aware leaf surfaces it instead of binding the caller's local.
|
|
Bad :: struct($T: Type) {
|
|
x: T;
|
|
y: LocalOnly;
|
|
}
|