diff --git a/lib/compare/dynamic.js b/lib/compare/dynamic.js index 56bb993..72a18ba 100644 --- a/lib/compare/dynamic.js +++ b/lib/compare/dynamic.js @@ -5,7 +5,7 @@ import { symbolDictIterator } from "../structures/dict.types.js"; import { symbolSetIterator } from "../structures/set.types.js"; import { symbolDict, symbolFunction, symbolList, symbolProduct, symbolSet, symbolSum } from "../structures/type_constructors.js"; import { prettyT } from "../util/pretty.js"; -import { compareBools, compareDoubles, compareOrderings, compareStrings, compareSymbols, compareUnits } from "./primitives.js"; +import { compareBools, compareDoubles, compareInts, compareOrderings, compareStrings, compareSymbols, compareUnits } from "./primitives.js"; import { compareDictIterators, compareDicts, compareFunctions, compareLists, compareProducts, compareSetIterators, compareSets, compareSums } from "./structures.js"; import { compareTypes } from "./type.js"; @@ -16,7 +16,7 @@ export const compareDynamic = x => y => const cannotCompareTypeVarInstances = _ => _ => { throw new Error("Cannot compare instance of type variables"); } const typeSymbolToCmp = new Map([ - [SymbolInt , compareDoubles ], + [SymbolInt , compareInts ], [SymbolBool , compareBools ], [SymbolDouble , compareDoubles ], [SymbolByte , compareDoubles ], diff --git a/lib/compare/primitives.js b/lib/compare/primitives.js index c3f3382..97aee00 100644 --- a/lib/compare/primitives.js +++ b/lib/compare/primitives.js @@ -2,14 +2,14 @@ export const compareInts = x => y => { if (typeof(x) !== 'bigint' || typeof(y) !== 'bigint') { - throw new Error(`was only meant to compare bigints! got ${x} and ${y}`); + throw new Error(`was only meant to compare bigints! got ${x} (${typeof(x)}) and ${y} (${typeof(y)})`); } return (x < y) ? -1 : (x > y) ? 1 : 0; }; export const compareDoubles = x => y => { if (typeof(x) !== 'number' || typeof(y) !== 'number') { - throw new Error(`was only meant to compare numbers! got ${x} and ${y}`); + throw new Error(`was only meant to compare numbers! got ${x} (${typeof(x)}) and ${y} (${typeof(y)})`); } return (x < y) ? -1 : (x > y) ? 1 : 0; };