Copy Pasting Code Repeatedly Causes Local Var Count To Increment
I've discovered that alternately copy-pasting and deleting this snippet of code:
var hello = 13
draw_text(0, 0, string(hello))
As the sole code of a draw event, results in the line
.localvar 3 hello X
Incrementing the value of X by 1 each time you do so.
https://user-images.githubusercontent.com/87032239/142721285-76573170-1879-45ca-9ee6-04b69a6527d5.mp4
Probably already known, but the cause for this is that every time var hello is written, a new code local hello gets created. When that code gets removed, UTMT doesn't check if hello is still in use / if it can be removed from the code locals list.
While it would be neat if UTMT could check that, it'd probably lead to weird behaviour. What if someone wanted to have a code local that isn't referenced by anything?
I believe this should be resolved by https://github.com/UnderminersTeam/UndertaleModTool/pull/2056, if it wasn't already.
Apparently not. Is the new compiler intended to delete unused local variables, or merge with existing ones if possible when creating them?
Hmm... Just took a quick look, and it tries to reuse the locals when recompiling, but doesn't search the whole list to reuse a local. Maybe we should change that behavior, depending on official GM behavior.