test: prove ordinary import binding modes

This commit is contained in:
2026-08-14 10:56:54 +09:00
parent 792b6ecbe5
commit 10e02a00ee
20 changed files with 1284 additions and 672 deletions

View File

@@ -246,7 +246,8 @@ does not return (e.g. a call to `abort`).
```
SourceFile = PackageClause { ImportDecl } { TopDecl } .
PackageClause = "package" ident ";" .
ImportDecl = "import" ident ";" .
ImportDecl = "import" ( ImportPath | ident ImportPath ) ";" .
ImportPath = ident { "." ident } .
```
- Every source file begins with a package clause. A directory of eligible
@@ -255,8 +256,13 @@ ImportDecl = "import" ident ";" .
canonical import identity.
- `import acme.codec;` loads the canonical package `acme.codec`. If that
package declares `package wire;`, the importing file sees its exported names
as `wire.Name`; `codec.Name` is not an additional binding. The import binding
is scoped to that source file. A sibling file must declare its own import.
as `wire.Name`; `codec.Name` is not an additional binding. An explicit alias
replaces only that visible qualifier: `import stable acme.codec;` exposes
`stable.Name`, not `wire.Name` or `codec.Name`. Both kinds of binding are
scoped to that source file. A sibling file must declare its own import.
Neither form exposes an imported declaration as a bare `Name`; ordinary
unqualified lookup remains limited to lexical, builtin, and same-package
declarations.
The package dependency graph is the sorted, deduplicated union of the real
imports in all eligible files. Self-import is rejected.
- An executable package is one declared `package main` and containing a
@@ -265,8 +271,9 @@ ImportDecl = "import" ident ";" .
colocated external-test wiring.
- Only names marked `export` (§5) are visible across module boundaries.
The implemented grammar remains dotted and unaliased. Quoted import paths,
explicit aliases, dot imports, and blank imports are not currently accepted.
Import paths remain unquoted and dotted. Grouped imports, quoted import paths,
dot imports, and blank imports are not implemented. In particular, `_` is
rejected as an alias rather than being treated as a blank import.
---