Adding more types to my stdlib functions. Cleaning up type checker

This commit is contained in:
Dustin Swan 2026-03-27 21:58:11 -06:00
parent 850219cdec
commit 2b710602d3
No known key found for this signature in database
GPG key ID: 30D46587E2100467
2 changed files with 30 additions and 51 deletions

View file

@ -32,6 +32,9 @@ function unify(t1: TypeAST, t2: TypeAST, subst: Subst): string | null {
// Same type name
if (a.kind === 'type-name' && b.kind === 'type-name' && a.name === b.name) return null;
// Same type var
if (a.kind === 'type-var' && b.kind === 'type-var' && a.name === b.name) return null;
// Type var binds to anything
if (a.kind === 'type-var') {
if (occursIn(a.name, b, subst)) return `Infinite type: ${a.name} occurs in ${prettyPrintType(b)}`;