Expand description
Defines the type-checking and name-resolution logic. This is what creates the symbolic IR.
§Type Checking Pipeline
The type checking module orchestrates the transformation of parsed AST into validated Symbolic IR. This is where Dada’s type system operates.
§High-Level Process
Type checking in Dada follows a multi-phase approach:
- Environment Setup - Create typing environments for scopes
- Symbol Resolution - Bind names to their definitions
- Type Inference - Infer types for expressions and variables
- Permission Checking - Validate ownership and borrowing
- Constraint Solving - Resolve type and permission constraints
- Validation - Ensure all semantic rules are satisfied
§Key Modules
§Core Infrastructure
env- Typing environments that track variables and their typesscope- Lexical scoping and name resolutionruntime- Runtime type information and checking context
§Type System
inference- Hindley-Milner type inference with permission extensionssubtype- Subtyping relations and coercion rulespredicates- Permission checking predicates (my,our,mut,ref)red- Ownership analysis (“Red” type system)
§Expression and Statement Checking
exprs- Expression type checking and inferencestatements- Statement validation and control flowblocks- Block expressions and local scopingplaces- Place expressions and borrowing analysis
§Declaration Processing
functions- Function signature and body checkinggenerics- Generic type parameter validationsignature- Function signature processing
§Utilities
resolve- Name resolution utilitiesreport- Error collection and diagnostic reportingmember_lookup- Method and field resolution
§The Checking Context
Most type checking operations take place within a checking context that maintains:
- Type environment - Maps variables to their types
- Permission environment - Tracks ownership states
- Scope information - Current lexical scope and accessible names
- Constraint accumulator - Collects type and permission constraints
- Error collector - Accumulates diagnostic messages
§Error Handling Philosophy
Dada’s type checker follows an “error recovery” approach:
- Continue checking even after encountering errors
- Collect multiple errors to report them all at once
- Use error types (
SymTy::Error) to prevent cascading failures - Provide diagnostic messages with source locations
This allows developers to see multiple issues at once rather than fixing them one by one.
§Integration with Salsa
All type checking is implemented as Salsa queries, providing:
- Incremental compilation - Only recheck what changed
- Memoization - Cache results of expensive operations
- Dependency tracking - Automatically invalidate stale results
- Parallel execution - Check independent modules concurrently
Modules§
- blocks 🔒
- debug 🔒
- env 🔒
- exprs 🔒
- fields 🔒
- functions 🔒
- generics 🔒
- inference 🔒
- Type and permission inference for Dada.
- live_
places 🔒 - member_
lookup 🔒 - modules 🔒
- places 🔒
- predicates 🔒
- Permission system and ownership predicates.
- red 🔒
- “Chains” are a canonicalized form of types/permissions. They can only be produced after inference is complete as they require enumerating the bounds of inference variables. They are used in borrow checking and for producing the final version of each inference variable.
- report 🔒
- resolve 🔒
- Code to resolve inference variables to concrete types and permissions.
- runtime 🔒
- scope 🔒
- scope_
tree 🔒 - signature 🔒
- statements 🔒
- stream 🔒
- subst_
impls 🔒 - subtype 🔒
- Subtyping relations and type conversions.
- temporaries 🔒
- to_red 🔒
- “Chains” are a canonicalized form of types/permissions. They can only be produced after inference is complete as they require enumerating the bounds of inference variables. They are used in borrow checking and for producing the final version of each inference variable.
- types 🔒
- universe 🔒
Traits§
- Check
Expr 🔒InEnv - Check
TyIn 🔒Env - Check an expression in a full environment. This is an async operation – it may block if insufficient inference data is available.