Type-check function signatures, calls, and return types #49
Loading…
Reference in a new issue
No description provided.
Delete branch "us3/type-check-function-signatures"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #3.
Migrates
Tyto#[salsa::interned](asTy/TyKind) ahead of schedule soTy::Fn { params, ret }has somewhere cheap to live, then implements:Expr::Fnchecking: resolves each param's declared type (falling back to a newTyKind::Error(Symbol)placeholder on failure, so a bad param type doesn't cascade intoUndefinedVariablefor every reference to it in the body), binds params into a fresh scope frame, checks the body in that scope, and compares the body's inferred type against the declared return type (ReturnTypeMismatch).Expr::Callchecking: resolves the callee, verifies it's aTyKind::Fn(NotCallableotherwise), checks arity (ArityMismatch) before pairing arguments against declared param types (ArgumentTypeMismatch, spanned at the offending argument).check_type_exprhelper, factoring the "resolve or push the right diagnostic" logic out ofcheck_letsoExpr::Fn's param/return resolution can share it.Expr::BracketCallandParam::SelfParamstay unhandled, per the design doc's explicit scope decision for this issue.Unit tests added in
ty.rsand end-to-end tests inqueries.rsfor all of the above.docs/type-checker-design.mdupdated throughout with the design decisions.Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_0115F8iYbo8n1xSxxQP4scjZ