Module checker
Expand description
Type checker and refinement validator (spec §§5–6, v0.1 §4.2, v0.2 §4.2).
Operates on a ResolvedCommons. Walks declarations, validates each
refinement against the spec’s predicate-base compatibility and combination
rules, then type-checks every function and method body.
v0.2 extensions:
- Record types (compatibility, field access, construction).
- Sum types and variant construction (qualified and unqualified).
- Methods (instance and static) with UFCS-style call resolution.
- Pattern matching with exhaustiveness checking.
- The
isoperator with binding flow into truthy contexts. - The built-in generic
Option[T].
Structs§
- Capability
Ctx - Mutable per-function context.
Capability bookkeeping for the checker — the
given-clause lifecycle and capability dispatch, grouped out ofCtx(v0.29.10). Empty (Default) for pure functions / non-context code. - Capability
Info - Per-capability info for checker dispatch within a handler body.
- Capability
OpInfo - Ctx
- Record
Check - The outcome of
check_record: the typed model (Errif the file had any error) and, on the error path, the best-effort partialexpr_typesthe checker computed before bailing. Analyse mode surfaces that partial map for.-member completion and signature help even on a broken buffer (ADR 0094); on the Ok path the types live in theTypedCommons, so this is empty. - Typed
Commons - Output of type checking.
Enums§
Functions§
- check
- check_
handler_ body - Check a single handler body (used for service and agent handlers).
- check_
invariants - Check an agent’s invariant declarations (v0.80 §14). Each predicate is a pure
Bool-typed expression over the agent’s state fields (referenced by bare name), plusimplies/is. The pass enforces: - check_
record check, recording binding edges intorefsat the checker’s resolution sites (v0.25). A fresh sink records nothing.- check_
state_ initialiser - v0.11: type-check an agent state-field initialiser (
field: T = init). The initialiser must be a static value of the field type — it is checked in an empty, pure scope (soself, parameters, capabilities, and effects are all out of reach) with the field type as the expected type, so refined literals admit (v0.9.4) and sum variants resolve. The init’s expression types are recorded intoexpr_typesfor emission; a singlebynk.agents.bad_state_initialiseris pushed on any failure. - compatible
tis usable whereuis expected.- named_
ty - Build a
Ty::Namedfor the given declaration. - record_
type_ refs - v0.25 (ADR 0053): record a binding edge for every
Namedreference inside a type-ref that resolved. Called alongside theresolve_type_ref*annotation sites;skipholds the enclosing fn’s type parameters (rigid vars are not type symbols). Handler signatures and body annotations never pass through the resolver’s reference walk, so these sites are their only recording point; where both passes run, assembly dedupes. - resolve_
type_ ref - resolve_
type_ ref_ in - v0.20a: like
resolve_type_ref, with a set of in-scope type parameters: aNamedreference matching one resolves toTy::Var(checked before the type-table lookup — a type parameter shadows a same-named declaration; the collision is diagnosed at the declaration). - type_
from_ decl - Build a
Tyfrom a TypeDecl name reference. - type_of
- type_
of_ block - zero_
value_ ts - The TypeScript zero-value expression for
type_ref(with an optional inline field refinement), orNoneif the type is not zeroable.