Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua5.3 decompilation special case issue #75

Open
tst2005 opened this issue Oct 13, 2020 · 6 comments
Open

lua5.3 decompilation special case issue #75

tst2005 opened this issue Oct 13, 2020 · 6 comments

Comments

@tst2005
Copy link

tst2005 commented Oct 13, 2020

  1. 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())

  1. 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.

@rocky
Copy link

rocky commented Mar 11, 2022

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

@rocky
Copy link

rocky commented Mar 13, 2022

I'll note that unluac doesn't have a problem decompling this.

@tst2005
Copy link
Author

tst2005 commented Mar 14, 2022

@rocky thanks for your feedback. There is a still maintained project on sourceforce, amazing !

@rocky
Copy link

rocky commented Mar 14, 2022

@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.)

@tst2005
Copy link
Author

tst2005 commented Mar 14, 2022

( and you never thought to move your projects elsewhere since the sourceforge scandal ? )

@rocky
Copy link

rocky commented Mar 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants