[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: To be closed variable from for in loop might not be closed
- From: Xmilia Hermit <xmilia.hermit@...>
- Date: Wed, 18 May 2022 23:13:52 +0200
Hi,
I found that the leaveblock function might generate an OP_CLOSE bytecode
which will not close the to be closed variable of a for in loop when the
break label generated in
https://github.com/lua/lua/blob/8426d9b4d4df1da3c5b2d759e509ae1c50a86667/lparser.c#L677-L680
already generated an OP_CLOSE bytecode which does not take the to be
closed variable from the loop into account.
The following code demonstrates the issue as the output "Close" is
expected but "Wrong" is printed.
local function test()
for k, v in next, {}, nil, setmetatable({}, {__close=function()
print("Close") end}) do
local function f()
return k
end
break
end
local x, y, z, w = 1, 2, 3, setmetatable({}, {__close=function()
print("Wrong") end})
end
test()
Regards,
Xmilia