Skip to main content

Module checker

Module checker 

Source
Expand description

Bidirectional type inference engine — T-AIR pass.

This module implements the type checker / inference engine for Bock. It walks an AIRNode module produced by the S-AIR lowering pass and:

  • Synthesizes types for expressions bottom-up (infer_expr).
  • Checks expressions against an expected type top-down (check_expr).
  • Annotates every node with a TypeInfo and records the resolved Type in an internal side-table keyed by NodeId.

§Architecture

check_module performs a two-sub-pass approach:

  1. Collect — all top-level function signatures are entered into the type environment so that mutually-recursive calls resolve.
  2. Check — each top-level item is fully type-checked.

During checking, the internal infer_node / check_node helpers recursively walk the AIR tree via &mut AIRNode, recording types in the side-table and stamping type_info on every node.

The public infer_expr / check_expr methods provide read-only access to the inference result for single nodes (no mutation — useful in tests and for downstream passes that want to query type of a specific node).

Structs§

TypeChecker
Bidirectional type checker / inference engine.
TypeEnv
Scoped type environment: maps variable/function names to their Types.