From 08c69eee0f869abacea80d1c29e467644906810e Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 22 Sep 2017 16:14:50 +0200 Subject: [PATCH] Simplify a = a = b -> a = b --- lslopt/lslfoldconst.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index c2eaf89..fb2af48 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -1053,13 +1053,14 @@ class foldconst(object): # We have a regular assignment either way now. Simplify the RHS. self.FoldTree(node['ch'], 1) - if child[0]['nt'] == child[1]['nt'] == 'IDENT' \ - and child[1]['name'] == child[0]['name'] \ - and child[1]['scope'] == child[0]['scope'] \ - or child[0]['nt'] == child[1]['nt'] == 'FLD' \ - and child[1]['ch'][0]['name'] == child[0]['ch'][0]['name'] \ - and child[1]['ch'][0]['scope'] == child[0]['ch'][0]['scope'] \ - and child[1]['fld'] == child[0]['fld']: + chkequal = child[1]['ch'][0] if child[1]['nt'] == '=' else child[1] + if child[0]['nt'] == chkequal['nt'] == 'IDENT' \ + and chkequal['name'] == child[0]['name'] \ + and chkequal['scope'] == child[0]['scope'] \ + or child[0]['nt'] == chkequal['nt'] == 'FLD' \ + and chkequal['ch'][0]['name'] == child[0]['ch'][0]['name'] \ + and chkequal['ch'][0]['scope'] == child[0]['ch'][0]['scope'] \ + and chkequal['fld'] == child[0]['fld']: parent[index] = child[1] return