lua-users home
lua-l archive

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


Hi!
 
C:\>luac54.exe -l -p -
do
   do
      local x = "not an upvalue"
   end
   goto a
   local y = "upvalue"
   function F() return y end
   ::a::
end
^Z
 
main <stdin:0,0> (8 instructions at 00000000027973e0)
0+ params, 2 slots, 1 upvalue, 2 locals, 3 constants, 1 function
        1       [1]     VARARGPREP      0
        2       [3]     LOADK           0 0     ; "not an upvalue"
        3       [5]     JMP             3       ; to 7
        4       [6]     LOADK           0 1     ; "upvalue"
        5       [7]     CLOSURE         1 0     ; 0000000002797640
        6       [7]     SETTABUP        0 2 1   ; _ENV "F"
        7       [8]     CLOSE           0
        8       [9]     RETURN          0 1 1   ; 0 out
 
 
The instruction #7 CLOSE treats register R0 as an upvalue, but R0 is not an upvalue here.
This might be a bug.
Either JMP 4 should be generated instead of JMP 3 to skip CLOSE,
or error should be raised: <goto a> at line 5 jumps into the scope of local 'y'.