upvalues not working

Issue #1260 invalid
Felix Moses
created an issue

ret = function() return x end

debug.setupvalue(ret , 1 , {x = 90})

love.errhand( ret() )

shows nil when it should return 90

Comments (2)

  1. Bart van Strien

    The function as written does not include an upvalue, but refers to a global instead. It needs to be preceded by something like local x to work. (Also note that you want 90 as a third argument, now you're changing it to a table instead.)

    Regardless, love uses an unmodified version of luajit, so if it doesn't work, it's not a bug in love.

  2. Denis Moreira dos Reis

    There is a discussion around this issue in which Mike Pall (creator of Luajit) participates in: https://github.com/LuaJIT/LuaJIT/pull/46 I can be wrong, but it is my understanding that once a path is traced-compiled, you won't be able reach a local variable using its identifier via the debug library (the identifier of a variable is meaningless, unless its a key in a table). Mike Pall set this issue asa "won't fix", so there isn't much you can do.

  3. Log in to comment