From fdd51289e8803a3ac961ad85a8cfd3bcfe44498d Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Mon, 8 May 2023 20:36:05 -0400 Subject: [PATCH] Fixed if elim --- verify.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/verify.js b/verify.js index ab67f4e..7de2bd4 100644 --- a/verify.js +++ b/verify.js @@ -183,6 +183,14 @@ function verifyIfElim(node) { return false; } + // Check that the current node matches the consequent + // of the if vertex + if (is_if_expression(node.parents[0].expression) && !node.expression.equals(node.parents[0].expression.children[1])) { + return false; + } else if (is_if_expression(node.parents[1].expression) && !node.expression.equals(node.parents[1].expression.children[1])) { + return false; + } + // Second parent is the antecedant of the first let match1 = is_if_expression(node.parents[0].expression) && node.parents[1].expression.equals(node.parents[0].expression.children[0]); @@ -191,6 +199,8 @@ function verifyIfElim(node) { let match2 = is_if_expression(node.parents[1].expression) && node.parents[0].expression.equals(node.parents[1].expression.children[0]) + + if (match1 == false && match2 == false) { return false; }