From 3afd961cf7030215dee19dd7ed0e079cb121e42e Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 8 Jan 2017 05:53:10 +0100 Subject: [PATCH] Fix functions with side effects being erroneously optimized. The function's SEF status was not taken into account when substituting functions with their values. This affected llModPow and llXorBase64Strings, both of which have a delay, and were erroneously substituted. But allow them to be substituted when in calculator mode. --- lslopt/lslfoldconst.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 4a2570d..08537bc 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -946,8 +946,9 @@ class foldconst(object): sym = self.symtab[0][node['name']] OptimizeParams(node, sym) - if 'Fn' in sym: - # Guaranteed to be side-effect free if the children are. + if 'Fn' in sym and ('SEF' in sym and sym['SEF'] or lslcommon.IsCalc): + # It's side-effect free if the children are and the function + # is marked as SEF. if SEFargs: node['SEF'] = True if CONSTargs: