metaworm / luac-parser-rs

lua bytecode parser written in Rust using nom, part of metaworm's lua decompiler, support lua51/lua52/lua53/lua54/luajit/luau https://luadec.metaworm.site/
https://luadec.metaworm.site/
204 stars 28 forks source link

Broken slot operation inlining side effect tracking #17

Open toxamin opened 1 year ago

toxamin commented 1 year ago

When given the following script:

local saved_value
local new_value = somefunc()
local to_ret = new_value - saved_value
saved_value = new_value
return to_ret

Metaworm's luadec incorrectly inlines the SUB to the return, as follows:

local r0_0 = nil
local r1_0 = somefunc()
r0_0 = r1_0
return r1_0 - r0_0