Broken script causes interpreter stack corruption
zackhasacat ran into this on Discord https://discord.com/channels/260439894298460160/262662689489158145/968558588853362718 with (effectively) this script:
being script
long zx
set zx to getpos zx
end
Note that getpos zx is a mistake as there is no zx axis. The GetPos opcode ignores any unknown axis, which corrupts the stack.
The above script is (correctly) compiled to
push 0
push 0
GetPos
OpFloatToInt
OpStoreLocalLong
Because GetPos doesn't push a float onto the stack in this case, OpFloatToInt ends up reinterpreting the local variable index as a float and then static_casting it to int (which in this case happens to mean the value remains the same), OpStoreLocalLong then proceeds to load this index as the value it's meant to store, and then tries to load the index to store the value to, which fails because the stack is empty.
We should probably check every other value-returning opcode to see if they actually return anything (or throw.)