From 1dde2a1fb93a2791df2abfbce4ec71cdcf2ca042 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 27 Oct 2017 11:20:42 +0200 Subject: [PATCH] Use lslfuncs.less instead of > >= < <= to ensure proper type handling. Float functions could be compared against integer args, or vice versa. --- lslopt/lslfoldconst.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index f742c1d..5e60bfd 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -1177,15 +1177,15 @@ class foldconst(object): # when FNCALL.max <= CONST: always false # when CONST < FNCALL.min: always true if ('max' in self.symtab[0][child[1]['name']] - and child[0]['value'] >= - self.symtab[0][child[1]['name']]['max'] + and not lslfuncs.less(child[0]['value'], + self.symtab[0][child[1]['name']]['max']) ): parent[index] = {'nt':'CONST', 't':'integer', 'SEF':True, 'value':0} return if ('min' in self.symtab[0][child[1]['name']] - and child[0]['value'] < - self.symtab[0][child[1]['name']]['min'] + and lslfuncs.less(child[0]['value'], + self.symtab[0][child[1]['name']]['min']) ): parent[index] = {'nt':'CONST', 't':'integer', 'SEF':True, 'value':1} @@ -1198,15 +1198,17 @@ class foldconst(object): # when CONST > FNCALL.max: always true # when CONST <= FNCALL.min: always false if ('max' in self.symtab[0][child[0]['name']] - and child[1]['value'] > + and lslfuncs.less( self.symtab[0][child[0]['name']]['max'] + , child[1]['value']) ): parent[index] = {'nt':'CONST', 't':'integer', 'SEF':True, 'value':1} return if ('min' in self.symtab[0][child[0]['name']] - and child[1]['value'] <= - self.symtab[0][child[0]['name']]['min'] + and not lslfuncs.less( + self.symtab[0][child[0]['name']]['min'], + child[1]['value']) ): parent[index] = {'nt':'CONST', 't':'integer', 'SEF':True, 'value':0}