lua5.3 decompilation special case issue
- Case without the issue
local function foo()
local a = 123
local b = a or 456 -- here there is "or a value"
return b
end
print(foo())
Decompiled:
-- Decompiled using luadec 2.2 rev: 895d923 for Lua 5.3 from https://github.com/viruscamp/luadec
-- Command line: decompil-bug.bytecode
-- params : ...
-- function num : 0 , upvalues : _ENV
local foo = function()
-- function num : 0_0
local a = 123
local b = a or 456
return b
end
print(foo())
- Case with the issue
local function foo()
local a = 123
local b = a or {} -- there is "or a table" not a value
return b
end
print(foo())
decompiled:
-- Decompiled using luadec 2.2 rev: 895d923 for Lua 5.3 from https://github.com/viruscamp/luadec
-- Command line: decompil-bug2.bytecode
-- params : ...
-- function num : 0 , upvalues : _ENV
local foo = function()
-- function num : 0_0
local a = 123
if not a then
local b = {}
end
return b
end
print(foo())
The b is define localy inside the if scope.
The value can not be used outside of the "if" block.
I know from my own experience that handling this kind of expression logic is difficult. It is mentioned as a problem in th 5.1 code that this was based on. See Status in https://github.com/sztupy/luadec51/blob/master/README.markdown
I'll note that unluac doesn't have a problem decompling this.
@rocky thanks for your feedback. There is a still maintained project on sourceforce, amazing !
@rocky thanks for your feedback. There is a still maintained project on sourceforce, amazing !
(I have a couple of projects that I still maintain on sourceforge that I somewhat maintain when I have bugs too.)
( and you never thought to move your projects elsewhere since the sourceforge scandal ? )
Wasn't aware of this. I will reconsider sourceforge. (And github is now Microsoft; gitlab or bitbucket then?) Speaking of dodgy info https://stackoverflow.com/a/67565648/546218 seems wrong based on what I have recently come to understand about Lua bytecode.