Expand description
Fase 3 expression typer.
Walks an ast::Expr tree and assigns a concrete DataType to
every node, using:
- Column scope (table → column → DataType) supplied by the caller as a closure so we don’t depend on the schema registry directly — keeps this module trivially testable.
- The cast catalog (
schema::cast_catalog) for implicit coercion paths. - The type-category preferred-member rule for tie breaks (PG
func_select_candidateheuristic, simplified).
Output is a TypedExpr mirroring the shape of Expr but with a
ty: DataType slot on every node. The runtime evaluator can use
that to skip the Value→Number tagging dance the current
expr_eval does at every step.
Scope today (Fase 3 starter): handles literals, columns, unary,
binary arith / comparison / logical, cast, IsNull, Between,
InList, Case, and built-in FunctionCall nodes resolved through the
static function catalog. The remaining gap is advanced polymorphic
signatures beyond lightweight cases such as COALESCE.
Subqueries / parameters / advanced polymorphism are out of scope.
This module is not yet wired into the parser → planner flow. It exists so Fase 3 Week 4+ can plug it in once the parser v2 emits Expr trees as the canonical projection / filter representation.
Structs§
- Typed
Expr - Resolved type for an expression node. Mirrors
Exprshape with an addedtyslot. Span is preserved so analyzer diagnostics can still point at the original token range.
Enums§
- Type
Error - Errors reported by the expression typer. All variants are recoverable diagnostics — the analyzer can collect several and emit them together rather than fail-fast like the parser.
- Typed
Expr Kind
Traits§
- Scope
- Closure-based column scope. The analyzer passes a closure that
resolves
(table, column)to aDataType, returningNoneif the column doesn’t exist in the active scope. Callers wire this to the schema registry (production) or a static map (tests).
Functions§
- type_
expr - Type a single expression against the given scope.