Expand description
Resolution and typechecking, elaborating straight into Core.
Stages 4 and 5 of docs/04-compiler-architecture.md
§4.1 — “modules, imports, name binding, hygiene scopes → resolved AST” and “HM + rows + effect
rows + capabilities → typed AST” — run as one pass that emits stage 6’s Core directly. §4.2
allows exactly three IRs; a separate resolved-but-untyped tree would be a fourth.
§Resolution is hygiene-aware
A reference resolves to a binding when binding.scopes ⊆ reference.scopes, innermost first.
That one rule is what makes the macro expander’s work mean something: a binding a macro
introduced carries a scope the call site does not have, so the call site cannot see it.
§What Phase 1 checks, and what it does not
Checked: HM inference with unification and let-polymorphism, ADTs (union), records (model),
nominal newtypes, match exhaustiveness, mandatory annotations on top-level signatures, and
the Stream/Signal/fold/durable types of §3.7.
Phase 2 adds §3.2’s effect inference. Every definition gets a row variable before any body
is checked; checking a body accumulates the latent row of everything it applies; the variable is
then bound to what accumulated. A mere reference to a function performs nothing — only
applying one does — which is the difference between inference and Phase 1’s syntactic collection,
and the reason fold(apply_event, …) is not itself effectful.
Mutual recursion needs no ordering: f’s row may be bound to a row mentioning g’s variable and
vice versa, and Subst::resolve_row computes the least fixed point because a row is a union.
Not checked, and named rather than implied: row polymorphism on records, trait constraints on
type variables, and var mutability (a var binding is checked as an ordinary immutable one).
Structs§
- Checker
- Def
- Program
- A checked module: everything the placement checker, the splitter and the runtime need.
- Signal
Decl - A top-level signal or stream declaration — the wiring of the program.
Enums§
- Identity
Decl - Who authenticates a program’s clients, as the program declared it.
- Mode
- What kind of file is being checked.
Functions§
- check_
module - Check a module that macro expansion has already run over.
- check_
module_ with - Check a module against the interfaces it imports — §3.6’s separate compilation.
- is_
impl_ method - Is this the name of a desugared impl method rather than something a program wrote?