From 221d8502eb335cc49935207a01c103cd7fb79025 Mon Sep 17 00:00:00 2001 From: Rob Simmons Date: Tue, 7 May 2024 13:12:55 -0400 Subject: [PATCH] Typescript issues with propogating severity --- src/client.ts | 9 ++++++++- src/language/check.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 38f2e77..a29e77e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -60,7 +60,11 @@ function loadJson(json: JsonData, facts: [Data, Data, Data][]): Data { } } else { throw new DusaError([ - { type: 'Issue', msg: `Could not load ${typeof json} as JSON data triples` }, + { + type: 'Issue', + msg: `Could not load ${typeof json} as JSON data triples`, + severity: 'error', + }, ]); } return ref; @@ -169,6 +173,7 @@ export class Dusa { { type: 'Issue', msg: `Asserted predicates must start with a lowercase letter and include only alphanumeric characters, '${pred}' does not.`, + severity: 'error', }, ]); } @@ -181,6 +186,7 @@ export class Dusa { msg: `Predicate ${pred} should have ${expected} argument${ expected === 1 ? '' : 's' }, but the asserted fact has ${arity}`, + severity: 'error', }, ]); } @@ -241,6 +247,7 @@ export class Dusa { { type: 'Issue', msg: "Cannot use 'solution' getter on programs with multiple solutions. Use sample() instead.", + severity: 'error', }, ]); } diff --git a/src/language/check.ts b/src/language/check.ts index 936e787..1fa5e16 100644 --- a/src/language/check.ts +++ b/src/language/check.ts @@ -44,6 +44,7 @@ export function checkPropositionArity( expectedArity === 1 ? '' : 's' }, but here it has ${arity}`, loc: occurrence, + severity: 'error', }); } } @@ -82,6 +83,7 @@ function checkFreeVarsInPremises(premises: ParsedPremise[]): type: 'Issue', msg: `Variable ${v} cannot be reused in a later premise because its first occurance was in an inequality`, loc, + severity: 'error', }); } } @@ -93,6 +95,7 @@ function checkFreeVarsInPremises(premises: ParsedPremise[]): type: 'Issue', msg: `Named wildcard ${dup} used multiple times in a rule.`, loc, + severity: 'error', }); } } @@ -129,6 +132,7 @@ function checkFreeVarsInPremises(premises: ParsedPremise[]): type: 'Issue', msg: `Only one side of an ${premise.type.toLowerCase()} can include a first occurance of a variable or a wildcard. The left side uses ${newA}, the right side uses ${newB}.`, loc: premise.loc, + severity: 'error', }); } break; @@ -183,6 +187,7 @@ export function checkFreeVarsInDecl(decl: ParsedDeclaration): Issue[] { type: 'Issue', msg: `Cannot include wildcard ${w} in the head of a rule.`, loc: decl.conclusion.loc, + severity: 'error', }); } @@ -192,12 +197,14 @@ export function checkFreeVarsInDecl(decl: ParsedDeclaration): Issue[] { type: 'Issue', msg: `Variable '${v}' used in head of rule but was first defined in an inequality.`, loc, + severity: 'error', }); } else if (!fv.has(v)) { errors.push({ type: 'Issue', msg: `Variable '${v}' used in head of rule but not defined in a premise.`, loc, + severity: 'error', }); } } @@ -222,6 +229,7 @@ function checkFunctionalPredicatesInTerm( msg: `The functional predicate '${pattern.name}' should be given ${expectedNum} argument${ expectedNum === 1 ? '' : 's' }, but is given ${pattern.args.length} here`, + severity: 'error', }, ]; } @@ -236,6 +244,7 @@ function checkFunctionalPredicatesInTerm( type: 'Issue', loc: pattern.loc, msg: `Built-in ${pattern.name} (${pattern.symbol}) expects no argument, has ${pattern.args.length}`, + severity: 'error', }, ]; } @@ -247,6 +256,7 @@ function checkFunctionalPredicatesInTerm( type: 'Issue', loc: pattern.loc, msg: `Built-in ${pattern.name} (${pattern.symbol}) expects two arguments, has ${pattern.args.length}`, + severity: 'error', }, ]; } @@ -259,6 +269,7 @@ function checkFunctionalPredicatesInTerm( type: 'Issue', loc: pattern.loc, msg: `Built-in ${pattern.name} (${pattern.symbol}) needs to have one of its arguments grounded by previous premises, and that is not the case here.`, + severity: 'error', }, ]; } @@ -277,6 +288,7 @@ function checkFunctionalPredicatesInTerm( }) needs to have all of its arguments grounded by previous premises, but the argument '${termToString( arg, )}' is not ground`, + severity: 'error', }, ]; } @@ -303,6 +315,7 @@ function checkFunctionalPredicatesInTerm( }) needs to have all but one of its arguments grounded by previous premises, but the arguments '${termToString( nonGround, )}' and '${termToString(arg)}' are both not ground.`, + severity: 'error', }, ]; }