UndertaleModTool icon indicating copy to clipboard operation
UndertaleModTool copied to clipboard

Malformed variables caused by automated simplification of expressions

Open Jesright73 opened this issue 2 years ago • 1 comments

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:

image

Code entry after changing the 1 to a 0 in the first line:

image

Reproducing steps

  1. Edit a code entry containing an expression with a compare operator followed by a math operation. example (image_angle + ((image_xscale == -1) * 180))
  2. Edit and compile the code entry
  3. Observe the parentheses are removed from around the compare operation result (image_angle + (image_xscale == -1 * 180)) No errors when effected code is run.
  4. Edit and compile the code entry again.
  5. 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

Jesright73 avatar Jul 03 '22 03:07 Jesright73

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

bug_brackets.zip

themabus avatar Jul 25 '22 05:07 themabus