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
TypeInfoand records the resolvedTypein an internal side-table keyed byNodeId.
§Architecture
check_module performs a two-sub-pass approach:
- Collect — all top-level function signatures are entered into the type environment so that mutually-recursive calls resolve.
- 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§
- Type
Checker - Bidirectional type checker / inference engine.
- TypeEnv
- Scoped type environment: maps variable/function names to their
Types.