UndertaleModTool icon indicating copy to clipboard operation
UndertaleModTool copied to clipboard

Bug: the compiler removes return statements sometimes

Open cgytrus opened this issue 2 years ago • 1 comments

Describe the bug

a return at the end of an if statement with other code in it removes the return when compiled

Reproducing steps

  1. Open a script (not sure if it works on the new functions thing, definitely works on legacy scripts)
  2. Put the following code at the beginning:
if(some_var) {
    do_something()
    return;
}
  1. Click away to compile the code
  2. Observe the return disappear

Setup Details

  1. commit 61d0f89
  2. win10 latest
  3. Will You Snail?

cgytrus avatar May 09 '22 20:05 cgytrus

This occurs because scripts automatically decompile with an unnecessary return at the end and I wanted to ignore that return to match bytecode. Thus, it can be fixed at AssemblyWriter.cs#1019, but maintaining 1:1 compilation will require removing the unnecessary return generation. Not that that's a high priority.

Jacky720 avatar May 24 '22 22:05 Jacky720