Expand description
Name resolution (spec §5.1, v0.1 §4.1, v0.2 §4.1).
Builds symbol tables for the commons and validates that:
- No two top-level items share a name (types, fns, methods are all named).
- Every
TypeRef::Namedresolves to a declared type. - Every free function call resolves to a function declaration.
- Every identifier in expression position resolves to a parameter, a
letbinding, orself(inside a method). - Constructor / static calls (
TypeName.method(args)) resolve either to the built-inT.ofof a refined type, a static method onT, or a variant constructor whenTis a sum type. - Record construction targets a declared record type and uses only declared fields.
- Method calls resolve via the receiver’s nominal type (the actual type check happens in the type checker).
On success returns a ResolvedCommons — the original AST plus
symbol tables the type checker consumes.
Structs§
- Cross
Context Capability - Snapshot of one exported capability in a consumed context, as needed for
v0.15 cross-context capability resolution. Operation signatures are
expressed in the consumed context’s own namespace (resolved against
consumed_typesat the call site, mirroringCrossContextService). - Cross
Context Capability Op - Cross
Context Info - Static information about the consuming context: the set of contexts it
consumes, and any aliases introduced viaas Aliasclauses. Used by the resolver to recognise cross-context service calls and by the checker to type them (v0.6 §4.2). - Cross
Context Service - Snapshot of one service in a consumed context, as needed for v0.6 cross-context type checking. The params and return type are expressed in the consumed context’s own namespace.
- Method
Table - Per-type method table built during resolution: keyed by method name,
values are clones of the
FnDeclfor that method. - Resolved
Commons - Output of resolution: the AST plus the symbol tables the checker needs.
Functions§
- compute_
is_ uses_ commons_ type - Is
namea type imported viausesof a commons specifically — the exact predicateResolvedCommons::is_uses_commons_typecaches asuses_commons_type_names, andbynk-emitneeds at two real call sites that must never disagree:emit_context_rebrands’s own two steps, “alias the import” and “rebrand the type” (its own doc comment, step 1 “Done in imports”, step 2 the rebrand itself, both inbynk-emit/src/emitter.rs) — an import narrower than the rebrand leaves an undefined name in the generated module; a rebrand narrower than the import leaves an alias imported and never used. - cross_
context_ service_ for - Project one local
on callhandler into theCrossContextServiceshape both sides of a cross-context contract check need — a caller resolving a consumed service (crate::symbols::build_cross_context_info) and a callee stamping its ownX-Bynk-Contractconstant (crate::contract::own_contract_hashes). Sharing this one projection is the whole correctness argument for that symmetry: if the two sides ever diverged, a working deployment would 409 on every call instead of only on real skew.Nonewhensdeclhas noon callhandler (e.g. an events-only or queue-only service). - resolve
- Resolve names in a single-file (or already-merged) commons. Use this
entry point only for self-contained Bynk programs. For multi-file
projects and
uses-resolving commons, useresolve_fileagainst a pre-built combined symbol table. - resolve_
file - Validate name references inside a single file’s items against an
already-built symbol table (
resolved.types,resolved.fns,resolved.methods). Used by the project-level driver after combining declarations from every file in a multi-file commons and from every commons brought in byuses. - resolve_
file_ record resolve_file, recording binding edges intorefsas the walk resolves them (v0.25). The project pass sets the sink’s per-file context; a fresh sink records nothing.