suggestions work again, improve error reporting

This commit is contained in:
Joeri Exelmans 2025-05-24 09:42:26 +02:00
parent 9050581a10
commit 69175c8cb1
12 changed files with 259 additions and 282 deletions

View file

@ -460,53 +460,6 @@
// }
// }
// function parseLiteral(text: string, type: string, env: Environment): [ResolvedType,Environment] {
// // dirty
// if (type === "Int") {
// return parseAsInt(text, env);
// }
// if (type === "Double") {
// return parseAsDouble(text, env);
// }
// return makeError(env, new Error("Failed to parse"));
// }
// function parseAsDouble(text: string, env: Environment): [ResolvedType,Environment] {
// if (text !== '') {
// const num = Number(text);
// if (!Number.isNaN(num)) {
// return [{
// kind: "value",
// i: num,
// t: Double,
// unification: new Map(),
// }, env];
// }
// }
// return makeError(env, new Error("Failed to parse as Double"));
// }
// function parseAsInt(text: string, env: Environment): [ResolvedType,Environment] {
// if (text !== '') {
// try {
// return [{
// kind: "value",
// i: BigInt(text),
// t: Int,
// unification: new Map(),
// }, env]; // may throw
// }
// catch {}
// }
// return makeError(env, new Error("Failed to parse as Int"));
// }
// const literalParsers = [parseAsDouble, parseAsInt];
// export function attemptParseLiteral(text: string, env: Environment): Dynamic[] {
// return literalParsers.map(parseFn => parseFn(text, env))
// .map(([resolved]) => resolved)
// .filter((resolved) => (resolved.kind !== "unknown" && resolved.kind !== "error")) as unknown as Dynamic[];
// }
// export function scoreResolved(resolved: ResolvedType, outPriority: (s:ResolvedType) => number) {
// const bias = outPriority(resolved);