lua-users home
lua-l archive

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


> Here is another (much simpler) test case, in pure Lua
> (that shows BTW that luaL_argerror is not the one to blame).

The problem is with the symbolic executor (symbexec, in ldebug.c). When
creating a closure, Lua (re)uses the opcode OP_GETUPVAL as a way to
tell that the new function has, as upvalue, an upvalue from the enclosing
function (Var, in your example); see listing:

1       (   4)    0 - GETUPVAL       0    0    0   --< get 'app'
2       (   4)    1 - GETTABLE       0    0  256   --< get field NoSuchName
3       (   4)    2 - CLOSURE        1    0    --< create closure with 1 upvalue
4       (   4)    3 - GETUPVAL       0    1    0   --< this is the upvalue!
5       (   4)    4 - CALL           0    2    1
6       (   5)    5 - RETURN         0    1    0

But 'symbexec' handles the OP_GETUPVAL as a real instruction,
and therefore reports that the value at register 0 (the one being called),
came from that upvalue.

Many thanks for your distilled example.

-- Roberto