ww imports: reject init bindings before recovery

This commit is contained in:
2026-08-22 04:27:23 +09:00
parent 4069eda942
commit 78c9eee82d
10 changed files with 789 additions and 15 deletions

View File

@@ -328,6 +328,21 @@ ImportPath = ident { "." ident } .
Neither form exposes an imported declaration as a bare `Name`; ordinary
unqualified lookup remains limited to lexical, builtin, and same-package
declarations.
- An import whose effective file-local qualifier is `init` is invalid. This
includes both `import init acme.codec;` and an unaliased import whose target
declares `package init;`. Each resolved occurrence is rejected at its first
import-spec token (the explicit alias when present, otherwise the first path
token) as `cannot import package as init - init must be a func`. The rejected
qualifier is never installed and does not participate in unused-import,
duplicate-binding, or declaration/import-collision recovery; consequently a
later `init.Name` independently reports an undefined `init`. Repeated invalid
occurrences each report the core error. Import resolution retains
precedence, so a missing target fails as missing without an additional
effective-`init` error. A resolved rejected occurrence remains source and
graph provenance for its exact dotted target: only its file-local qualifier
binding is absent. Canonical package, import, graph, action, artifact,
symbol, `.wwi`, publication, and persistence identity never derives from the
rejected qualifier or from the target's declared name.
- `import _ acme.codec;` is a blank side-effect import. The lone `_` creates no
qualifier, exposes no bare declaration, and is never diagnosed as unused.
It is nevertheless a real import occurrence: resolution and all missing,