lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 20.05.2015 um 07:24 schröbte "书呆彭, Peng Yi":

as Roberto said, it is due to an optimization in the opcode generator.
before Lua changes(or should I say fixes?) this inconsistent hook behavior,
you can use a simple workaround: just reserve a new stack slot and copy the
to-be-returned local variable there, then return the new one.

in your test script, it is something like:

-------------------------------------
   local function func ()
     local a, b, c, d, e = <...>
     <...>
     local __ret = b
     return __ret
   end
-------------------------------------

Thanks again, but I will probably use a line-hook for now. I'd like to avoid parsing Lua files of possibly different Lua versions and patching their source code. I can't see an easy and reliable way to do that automatically.

Philipp