This commit is contained in:
Joeri Exelmans 2025-05-23 19:55:22 +02:00
parent 0d3ccee7d5
commit 664f31447f
2 changed files with 8 additions and 8 deletions

View file

@ -157,7 +157,7 @@ export const unify = (typeA, typeB) => {
// A and B are not typevars
if (typeA.symbol !== typeB.symbol) {
throw new IncompabibleTypesError(typeA, typeB);
throw new IncompatibleTypesError(typeA, typeB);
}
const subs = zip(typeA.params, typeB.params)
@ -171,11 +171,11 @@ export const unify = (typeA, typeB) => {
}
catch (e) {
if (e instanceof SubstitutionCycle) {
throw new IncompabibleTypesError(typeA, typeB, e);
throw new IncompatibleTypesError(typeA, typeB, e);
}
if (e instanceof IncompabibleTypesError) {
if (e instanceof IncompatibleTypesError) {
// nest errors to get a nice trace of what went wrong
throw new IncompabibleTypesError(typeA, typeB, e);
throw new IncompatibleTypesError(typeA, typeB, e);
}
throw e;
}

View file

@ -1,7 +1,7 @@
import assert from "node:assert";
import { getDefaultTypeParser } from "../lib/parser/type_parser.js";
import { IncompabibleTypesError, subsitutionsEqual, unify } from "../lib/generics/unify.js";
import { IncompatibleTypesError, subsitutionsEqual, unify } from "../lib/generics/unify.js";
const assertSubsitutionsEqual = (m1,m2) => {
@ -27,7 +27,7 @@ assert.throws(
mkType("Bool")
);
},
IncompabibleTypesError,
IncompatibleTypesError,
);
assertSubsitutionsEqual(
@ -69,7 +69,7 @@ assert.throws(
mkType("[b] -> b"),
);
},
IncompabibleTypesError,
IncompatibleTypesError,
);
assertSubsitutionsEqual(
@ -90,7 +90,7 @@ assert.throws(
mkType("b -> (c -> b)"),
);
},
IncompabibleTypesError,
IncompatibleTypesError,
// String,
);