Skip to main content

Module locals

Module locals 

Expand description

v0.31 (ADR 0064): the local-binding sink.

Records each local binding — let/let <-, lambda/fn/handler parameters, and match-arm pattern bindings — with its lexical scope range, so the LSP can offer/navigate locals (the recurring deferral: the v0.25 index, the v0.27 hints, the v0.28 tokens, and v0.30.2 completion all stop at top-level symbols for want of a scope-at-offset query).

Mirrors HintSink: a &mut sink threaded through the checker, recording at the binding sites as types are computed — so it survives a transient error at the sites the checker still reaches, and (like hints) it is not part of the Ok(TypedCommons) payload. Scope ranges are taken from the enclosing block/body/arm span the checker already has at each binding site, not re-derived — so nesting and shadowing are the checker’s own (tested) scoping, resolved in locals_at. Only synthetic files are muted (locals serve completion/navigation in test files too).

Structs§

LocalBinding
One local binding: its name, the binding-name span (the def site), its rendered type (Bynk surface syntax, as hints render — no Ty on the surface), and the source range over which it is in scope.
LocalsSink
Records local bindings per file. A fresh sink records nothing until enter_file attributes it.

Functions§

binding_at_def
The single binding whose def-name span covers offset — the definition-site query (for references/rename on a local’s declaration).
locals_at
The local bindings in scope at offset, deduplicated by name with the innermost/latest definition winning (shadowing) — the completion and navigation query.

Type Aliases§

FileLocals
Project-relative source path → that file’s local bindings, in source order.