fix(resolver): type-author-aware + local-safe bare-TYPE gate; R3 model escalated [stdlib E1 attempt-3]

R1 (type-author-aware gate): the bare-TYPE visibility gate now requires a
flat-import-reachable TYPE author (struct/enum/union/error-set/protocol/foreign
class). A same-name flat VALUE/FUNCTION no longer makes a namespaced-only TYPE
bare-visible — the name-only `m.names.contains` check (attempt-2) is replaced by
`moduleAuthorsType` (kind-checked via `RawDeclRef`). Regression 0745.

R2 (no local false-positive): a block-local type clobbers the global type-table
entry for its name (`registerStructDecl`'s findByName-orelse-intern +
updatePreservingKey), so it IS the resolved type — never a namespaced-only leak.
A new `local_type_names` set, populated at both block-local type-decl paths,
exempts such names from the gate. Regression 0746.

readme.md: drop the false "transitively" claim — flat-import bare visibility for
functions and constants is NON-transitive (0706).

R3 (foundational model consistency) is ESCALATED, not resolved here — see the
attempt-3 worker report. Ground truth: making the TYPE gate single-hop (to match
the value/function model) breaks ~19 tests, ~13 of them library-INTERNAL generic
refs (e.g. `List.append`'s `alloc: Allocator`, lowered in the caller's source
context). That needs source-pinning generic instantiation to the template's
defining module — a separate architectural piece beyond E1's leaf-cut scope, and
proven risky (a `monomorphizeFunction` pin broke 4 FFI objc-block tests and did
not even take, since template method bodies lack a reliable `source_file`). The
TYPE gate therefore stays on the (type-author-aware) transitive flat closure for
E1; the non-transitive reconciliation is a routed follow-up.
This commit is contained in:
agra
2026-06-07 17:51:09 +03:00
parent 7188481761
commit 4bd57c857e
13 changed files with 179 additions and 72 deletions

View File

@@ -400,12 +400,13 @@ A bare call to a name that two or more flat imports both provide is ambiguous an
is rejected; qualify it with a namespaced import (`m :: #import …; m.fn()`).
A **namespaced** import only binds its alias: reach the module's members as
`m.name`. Bare-name visibility joins over flat (`#import "…"`) imports only —
transitively (a flat import of a flat import is visible) — never over a
namespaced alias. A bare reference to a namespaced-only import's member —
function, module constant, or **type** — is not visible and is rejected (`type
'X' is not visible; #import the module that declares it`); qualify it as
`m.name`.
`m.name`. Bare-name visibility joins over flat (`#import "…"`) imports, never over
a namespaced alias. For **functions and constants** that join is non-transitive: a
flat import of a flat import is NOT bare-visible (when `A` imports `B` and `B`
imports `C`, `A` does not see `C`'s top-level names — qualify them). A bare
reference to a namespaced-only import's member — function, module constant, or
**type** — is not visible and is rejected (`type 'X' is not visible; #import the
module that declares it`); qualify it as `m.name`.
### Implicit Context