List spread type checking

This commit is contained in:
Dustin Swan 2026-03-26 22:19:09 -06:00
parent bc5027ddc1
commit 1a65db6aac
No known key found for this signature in database
GPG key ID: 30D46587E2100467

View file

@ -252,7 +252,11 @@ function check(expr: AST, expected: TypeAST, env: TypeEnv, subst: Subst): string
if (expr.kind === 'list' && exp.kind === 'type-apply' && exp.constructor.kind === 'type-name' && exp.constructor.name === 'List') { if (expr.kind === 'list' && exp.kind === 'type-apply' && exp.constructor.kind === 'type-name' && exp.constructor.name === 'List') {
const elemType = exp.args[0]; const elemType = exp.args[0];
for (const elem of expr.elements) { for (const elem of expr.elements) {
if (elem.kind === 'list-spread') continue; if (elem.kind === 'list-spread') {
const err = check(elem.spread, exp, env, subst);
if (err) return err;
continue;
}
const err = check(elem, elemType, env, subst); const err = check(elem, elemType, env, subst);
if (err) return err; if (err) return err;
} }