Skip to content

Commit

Permalink
fixed bad assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaniBilby committed Mar 25, 2024
1 parent ee51925 commit 929f00e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/compiler/codegen/expression/precedence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function ApplyPrecedence(syntax: Term_Expr) {
rpn.push(op_stack.pop()!);
}

// This could probably be optimised in the future to not use a stack, and just manipulate a raw root node
const stack = new Array<PrecedenceTree>();
while (rpn.length > 0) {
const token = rpn.shift()!;
Expand All @@ -85,8 +86,8 @@ export function ApplyPrecedence(syntax: Term_Expr) {
}

const root = stack.pop()!;
assert(typeof root === "string", "Expression somehow has no arguments during precedence calculation");
assert(stack.length != 0, "Expression somehow has only operators during precedence calculation");
assert(typeof root !== "string", "Expression somehow has no arguments during precedence calculation");
assert(stack.length == 0, "Expression somehow has only operators during precedence calculation");

return root;
}
Expand Down

0 comments on commit 929f00e

Please sign in to comment.