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) → codegenStructs§
- Call
Instance - One call of a generic function, as the checker solved it.
- Indexed
Type Error - 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.
- Located
Type Error - A type error and the top-level function it was found in —
Nonefor a## Mainstatement. 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
TypeEnvfor 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
Nonefor 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 wordsQuantity 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
stmtsas 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
TypeEnvis not: its variables are one flat map, so a function’s ownxand the program’sxshare an entry there.