From 4302ea846d03961b3ce80576025b2c5f7abd11a2 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Tue, 21 Apr 2015 06:09:57 +0200 Subject: [PATCH] Don't fall through after optimizing a negable comparison, as it's folded already and the variables were incorrectly set and broke our invariants. --- lslopt/lslfoldconst.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 486e2a7..f4833bb 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -769,9 +769,9 @@ class foldconst(object): # the number of cases to check. # a<=b --> !(a>b); a>=b --> !(a !(a==b) node['nt'] = {'<=':'>', '>=':'<', '!=':'=='}[nt] - node = parent[index] = {'nt':'!', 't':node['t'], 'ch':[node]} + parent[index] = {'nt':'!', 't':node['t'], 'ch':[node]} self.FoldTree(parent, index) - # Fall through to optimize as '<' or '>' or '==' + return if nt == '>': # Invert the inequalities to avoid doubling the cases to check.