Closed Jacky720 closed 5 months ago
Download the artifacts for this pull request here:
GUI:
CLI:
a < b < c
is valid GML syntax (it's accepted by GameMaker's compiler), so I think it might be better/saves parentheses to instead allow multiple comparison operators next to eachother in the compiler (like it already is possible with math), which I already did for UTMTCE. Maybe I should PR that.
What does GameMaker's compiler produce in this case? If it's like Python, it would be a < b && b < c
, but if it's actually producing (a < b) < c
as in turning the first comparison from boolean to number, we should decompile that.
Yeah, I just spun up a dummy project, that's exactly what it's doing.
"a < b" is false, 0, and 0 < c. (a < b) < c
is the opposite of the code's intent, of course, but consistent with the new decompilation (and the mod tool compiler can handle it).
Even though it is a compiler bug, let's just always force parattheses for now on. Makes that code way more readable and prevents user bugs.
Description
Minor fix for a bug reported on Discord where the code
x -= ((1 + statetime) < (2 + statetime)) < 4
would decompile asx -= (1 + statetime) < (2 + statetime) < 4
.Caveats
Only the possible exceptions where parentheses might be helpful to other, yet rarer, expressions, which would have already been decompiling incorrectly.
Notes
N/A