UndertaleModTool
UndertaleModTool copied to clipboard
Malformed variables caused by automated simplification of expressions
Describe the bug
Parentheses removal caused by the expression simplification procedure performed by UMT during code entry edit/compiling can lead to malformed variables, especially when expressions include compare operators.
Original code from AM2R before editing:
Code entry after changing the 1
to a 0
in the first line:
Reproducing steps
- Edit a code entry containing an expression with a compare operator followed by a math operation.
example
(image_angle + ((image_xscale == -1) * 180))
- Edit and compile the code entry
- Observe the parentheses are removed from around the compare operation
result
(image_angle + (image_xscale == -1 * 180))
No errors when effected code is run. - Edit and compile the code entry again.
- Notice the compare operator's number is now combined with the adjacent math operation.
result
(image_angle + image_xscale == -180)
Attempting to run the effected code will now result in a "Malformed Variable" error.
Setup Details
UndertaleModTool v:85430c5 (master) OS: Windows 10 21H1 Game: Another Metroid 2 Remake Code entry from AM2R used in example: gml_Object_oSpaceJumpTrail_Draw_0
I seem to have encountered the same problem but with decompiler not compiler, i.e. presented Decompiled code is non working because of missing brackets. It appears to have been parsed correctly in v0.3.0 and was already broken in v0.3.5.8 I didn't check versions in between. This is still present in '674c5d8' bleeding edge.
edit:
label = 'a'; a = 0.1 + ((label == 'a') * 0.2);
2nd line will be decompiled to a = (0.1 + (label == "a" * 0.2))
which of course is not an valid statement