Skip to main content

Module checker

Module checker 

Source
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
  • return types match the enclosing function’s declared return type
  • break and continue only 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 CheckType and ScopeItem, plus private type-matching utilities.

Functions§

collect_fn_names 🔒
Collects all function names from a stdlib [Module] tree into out.