Skip to content
La3 Docs
Browse docs

Type Checker

Inference, operator typing, field and method resolution, casts, exhaustiveness, and bounds.

Source of truth

The type checker produces concrete types that later passes consume instead of re-inferring.

  • Every expression receives a concrete type before lowering.
  • Unconstrained integer and float literals are defaulted.
  • Unknowns are tolerated only where the frontend intentionally remains lenient.
  • Codegen should reject any residual type it cannot represent.

Operator typing

Operators are typed by rule, not by runtime guessing.

  • Arithmetic requires compatible numeric operands.
  • Comparisons and logical operators return bool.
  • Bitwise operators require integer operands.
  • ?? and ?. require optional values.
  • ? requires a compatible enclosing return type.

Fields and methods

Known receiver types produce useful diagnostics for missing fields and methods.

When the checker knows a struct, tuple, enum, or modelled builtin receiver, it can report that a field or method does not exist at the exact span. When the receiver is still generic or unknown, it stays conservative instead of inventing a false error.

Layout information

The checker also classifies layouts and drop requirements for backend work.

  • Structs, tuples, arrays, and enums get by-value layout information.
  • Heap-owning values are marked as needing drop.
  • Layout and drop classification become part of the backend contract.