From ac254efb77a81999cfca702565dbc847cbcd4e87 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 2 Jun 2018 17:28:09 +0200 Subject: [PATCH] Minor details Assert that it can't be key where we say it can't, and that it is integer where we say it must. Adjust some comments. --- lslopt/lslfoldconst.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 6b755ef..b4d537c 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -857,9 +857,11 @@ class foldconst(object): return # Can't be key, as no combo of addition operands returns key - # All these types evaluate to boolean False when they are - # the neutral addition element. + assert optype != 'key' + if optype in ('string', 'float', 'list'): + # All these types evaluate to boolean False when they are + # the neutral addition element. if lnt == 'CONST' and not lval.value: # 0. + expr -> expr # "" + expr -> expr @@ -928,12 +930,15 @@ class foldconst(object): type(lval.value)] return + # Nothing else to do with addition of float, string or list return # Must be two integers. This allows for a number of # optimizations. First the most obvious ones. + assert optype == 'integer' # just to make sure if lnt == 'CONST' and lval.value == 0: + # 0 + x = x parent[index] = rval return