Expand description
Static type checker for rl - runs after parsing, before evaluation.
The checker walks the AST and verifies:
- Variable and constant declarations match their declared types
- Binary/unary operators receive compatible operand types
- Function calls receive the correct number and types of arguments
returntypes match the enclosing function’s declared return typebreakandcontinueonly appear inside loops- Array elements are all the same type
It also populates TypeChecker::hovers - a side-table of
(Span, markdown) pairs used by the LSP hover provider.
§Two-pass function checking
TypeChecker::check does two passes over the statement list:
first it pre-declares all top-level FunctionDeclarations so they
are visible to each other regardless of order, then it checks every
statement body. This allows mutual recursion at the top level.
Re-exports§
pub use structs::TypeChecker;
Modules§
- operators
- Operator type-checking - binary, unary, and index-assign.
- scope
- Scope management and name lookup for the type checker.
- statements
- Statement-level helpers shared between expression and statement checking.
- structs
- Core data structures for the type checker.
- types
- Helper methods on
CheckTypeandScopeItem, plus private type-matching utilities.
Functions§
- collect_
fn_ 🔒names - Collects all function names from a stdlib [
Module] tree intoout.