Skip to main content

Module check

Module check 

Source
Expand description

Bidirectional type checker for the LOGOS compilation pipeline.

Replaces TypeEnv::infer_program() with a proper constraint-solving pass that eliminates Unknown for field access, empty collections, option literals, pipe receives, inspect arm bindings, and closure call expressions.

§Architecture

AST
 │
 ├── preregister_functions   ← forward-reference pre-pass
 │
 └── infer_stmt / infer_expr ← bidirectional checking
          │
          └── UnificationTable ← Robinson unification (from unify.rs)
                   │
                   └── zonk → TypeEnv (LogosType) → codegen

Structs§

CallInstance
One call of a generic function, as the checker solved it.
IndexedTypeError
One typechecker finding with the top-level statement it belongs to.
Instantiations
What the checker solved at every generic site of a program — the input to monomorphization.
LocatedTypeError
A type error and the top-level function it was found in — None for a ## Main statement. A checked program has no source spans left (lowering writes functions of its own), so the function is the location a report can give.

Enums§

Site
A node of the checked program, by address. The checker and a later pass over the SAME statements agree on it without the AST carrying ids.

Functions§

check_program
Check a LOGOS program and return a typed TypeEnv for codegen.
check_program_collect
Collect EVERY failing top-level statement instead of bailing at the first.
check_program_located
check_program, reporting which top-level function a failure is in.
first_undeclared_type
The first type the program names that nothing supplies, with where it is named: the index of the top-level statement that names it, or None for a field of a declared record or variant (a declaration is not a statement). A name is supplied by the registry (a record, enum or alias the program declares or imports, a builtin, an intrinsic generic), by the language itself (codegen::types::is_language_type_name, and the dimension words Quantity of <Dimension> takes, Dimension::by_name), or as a type parameter the declaration itself introduces. Run on the program the parser returned, whose top-level statements align with its statement spans, so a statement’s refusal is located. A written type counts wherever it stands: a construction, a collection’s element type, an annotation, a typed fetch, a function’s parameters and return type, a record’s or variant’s field types.
infer_instantiations
Check stmts as far as each statement goes — a failing statement does not stop the rest — and answer what every generic site was solved at. The input to monomorphization; a backend with no generics of its own reads which instance each call and construction needs from here.
root_binding_types
The type of every binding the program’s ROOT declares, as the checker settled it once the whole program was read. Exact where TypeEnv is not: its variables are one flat map, so a function’s own x and the program’s x share an entry there.