More type checking

This commit is contained in:
Dustin Swan 2026-03-26 20:01:06 -06:00
parent 668ee3e4d8
commit de83eb6fcd
No known key found for this signature in database
GPG key ID: 30D46587E2100467
2 changed files with 22 additions and 0 deletions

View file

@ -127,6 +127,23 @@ function infer(expr: AST, env: TypeEnv, subst: Subst): TypeAST | null {
return null;
}
case 'record-update': {
const recType = infer(expr.record, env, subst);
if (!recType) return null;
const resolved = applySubst(recType, subst);
if (resolved.kind !== 'type-record') return null;
for (const [key, value] of Object.entries(expr.updates)) {
const field = resolved.fields.find(f => f.name === key);
if (field) {
const err = check(value, field.type, env, subst);
if (err) warn(err, value);
}
}
return resolved;
}
case 'apply': {
const funcType = infer(expr.func, env, subst);
if (!funcType) return null;