Bug: 'break' may not properly close variable in a 'for' loop
Function 'leaveblock' was generating "break" label before removing variables from the closing block. If 'createlabel' created a 'close' instruction (which it did when matching a goto/break that exited the scope of an upvalue), that instruction would use the wrong level.
This commit is contained in:
@@ -360,6 +360,26 @@ do
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
-- bug in 5.4.4: 'break' may generate wrong 'close' instruction when
|
||||
-- leaving a loop block.
|
||||
|
||||
local closed = false
|
||||
|
||||
local o1 = setmetatable({}, {__close=function() closed = true end})
|
||||
|
||||
local function test()
|
||||
for k, v in next, {}, nil, o1 do
|
||||
local function f() return k end -- create an upvalue
|
||||
break
|
||||
end
|
||||
assert(closed)
|
||||
end
|
||||
|
||||
test()
|
||||
end
|
||||
|
||||
|
||||
do print("testing errors in __close")
|
||||
|
||||
-- original error is in __close
|
||||
|
||||
Reference in New Issue
Block a user