Skip to content
beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

05.2 Name resolution

Scope-first lookup, import precedence, and ambiguity errors.

Name resolution

Name resolution is the compiler answering which declaration did you mean? When the answer is “more than one,” you get an ambiguity error. That is a feature.

  1. Local scope (parameters, let bindings)
  2. Enclosing scopes
  3. Imports (including aliases)
  4. Module scope
flowchart TD
  accTitle: Name lookup order
  accDescr: A name reference is checked against local bindings first, then enclosing scopes, imports and module scope.
  N[Name reference] --> L{Local binding?}
  L -->|yes| OK[Use local]
  L -->|no| E[Enclosing scopes]
  E --> I[Imports]
  I --> M[Module scope]

If two imports provide the same unaliased name, the compiler errors. Fix with as aliases; do not rely on import order to “win.”

Assuming use Foo; lets you shadow a local Foo is a fast path to embarrassment. Locals win.

Fully qualified paths follow module nesting declared by files and mod statements. When lost, beskid dev syntax analyze with a one-file repro beats staring at folders.

pub use re-exports