Expand description
Name resolution (spec chapter 6): modules, imports, visibility, scopes.
Resolution runs in two passes over all modules of a project, together with the std modules:
- Collect: the top-level names of every module, the members of types (enum variants and
the functions of inherent
implblocks), then the imports and the import graph. - Resolve: every name in types, expressions and patterns, with local scopes.
Section order is layout, not visibility (chapter 2, rule 2.6), which is why the first pass sees the whole project before anything is resolved. The result is a table from syntax nodes to what they name, for the type checker (M4), plus the diagnostics of chapter 6.
Structs§
- Def
- A declaration.
- DefId
- Identifies a declaration.
- Local
- A local variable.
- LocalId
- Identifies a local variable, parameter or pattern binding.
- Module
Id - Identifies a module.
- Module
Info - Facts about a module after resolution.
- Module
Input - One parsed module given to the resolver.
- Project
Info - Facts about the project that resolution needs.
- Resolved
- The result of name resolution.
Enums§
- DefKind
- The kinds of declarations.
- Payload
- The payload form of a variant.
- Res
- What a name in the source refers to.
- Role
- What a module is for.
Functions§
- check_
target - E0704 for every module of a build for
targetthat is not available for it.builtsays which modules the build contains; std modules are always available. - is_
pascal_ case [A-Z][A-Za-z0-9]*- is_
snake_ case [a-z][a-z0-9]*(_[a-z0-9]+)*- resolve
- Resolves a project.
modulesmust contain the std modules (wolf_std::MODULES, parsed by the caller, with rolesRole::PreludeandRole::Std) and every module of the project. - suggest
- The closest candidate to
name, if it is close enough. Ties go to the alphabetically first. The candidate closest toname, if one is close enough to be a likely typo.