test: prove declared package import semantics
This commit is contained in:
22
docs/spec.md
22
docs/spec.md
@@ -249,13 +249,25 @@ PackageClause = "package" ident ";" .
|
||||
ImportDecl = "import" ident ";" .
|
||||
```
|
||||
|
||||
- Every source file begins with a package clause. A directory of `.ww`
|
||||
files sharing one package name compiles as a single module.
|
||||
- `import foo;` makes module `foo`'s exported names available as
|
||||
`foo.Name`. Self-import is rejected.
|
||||
- An executable's entry module is `package main;` with a `fn main`.
|
||||
- Every source file begins with a package clause. A directory of eligible
|
||||
`.ww` files sharing one declared package name compiles as one package. The
|
||||
declared name need not equal the directory name or the final component of its
|
||||
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.
|
||||
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
|
||||
`fn main`; path and directory spelling do not classify commands. An ordinary
|
||||
import of a package declared `main` is rejected, except for the toolchain's
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## 5. Declarations
|
||||
|
||||
Reference in New Issue
Block a user