Closed KrsityKu closed 5 months ago
Congratulations, you've found a decade-old bug 😁
This is broken since 36759cacba2675c5a69ff32f0c21f076a90c0735 in which the constant was moved from the class to the module's top level. Will fix, thanks for the report.
As for the 2.;
, I still have to look deeper into this one.
Not necessary in this case because it was easy to reproduce for me, but in general, could you please use flag -y
for getting a full backtrace when reporting errors? It is usually disabled because Python backtraces can be a bit daunting to users, but for bug reporting they are most useful to the developers.
The constant folding optimizer does much more than folding constants, despite its name. It's the one that removes side-effect-free (SEF) statements, for one, so the presence of the 2.;
is expected. There's a bit of a mix of responsibilities in the constant folding and the dead code removal modules, in the interest of speed, to avoid making multiple passes. If you disable constant folding, you won't get SEF statements removed, even if that sounds like it might be the task of DCR. Actually, that code is not "dead", because in the optimizer, "dead" code is defined as code that is never reached, and execution certainly reaches the statement 2.;
.
In this case, there's an additional problem where, after fixing that issue, it needs another pass to fully optimize the resulting script.
could you please use flag
-y
for getting a full backtrace
I'll keep that in mind, though I usually use the online version to narrow down a small reproducible.
Optimizer produces the error:
AttributeError: 'optimizer' object has no attribute 'PythonType2LSL'
When optimizing the following code with Constant Folding and Dead Code RemovalThis is the smallest reproducible I managed to get that throws the error, my code uses a lot of macros and constant folding that eventually results in the same error.
Also, I've noticed that with only Dead Code Removal enabled. (Constant folding off) it produces this snippet:
That
2.;
is pointless.