CallInfo bit CIST_CLSRET broken in two
Since commit f407b3c4a, it was being used for two distinct (and
incompatible) meanings:
A: Function has TBC variables (now bit CIST_TBC)
B: Interpreter is closing TBC variables (original bit CIST_CLSRET)
B implies A, but A does not imply B.
This commit is contained in:
@@ -515,7 +515,7 @@ else
|
||||
print "testing yields inside hooks"
|
||||
|
||||
local turn
|
||||
|
||||
|
||||
local function fact (t, x)
|
||||
assert(turn == t)
|
||||
if x == 0 then return 1
|
||||
@@ -642,7 +642,7 @@ else
|
||||
|
||||
|
||||
print "testing coroutine API"
|
||||
|
||||
|
||||
-- reusing a thread
|
||||
assert(T.testC([[
|
||||
newthread # create thread
|
||||
@@ -920,7 +920,7 @@ do -- a few more tests for comparison operators
|
||||
until res ~= 10
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
local function test ()
|
||||
local a1 = setmetatable({x=1}, mt1)
|
||||
local a2 = setmetatable({x=2}, mt2)
|
||||
@@ -932,7 +932,7 @@ do -- a few more tests for comparison operators
|
||||
assert(2 >= a2)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
run(test)
|
||||
|
||||
end
|
||||
@@ -1037,6 +1037,31 @@ f = T.makeCfunc([[
|
||||
return *
|
||||
]], 23, "huu")
|
||||
|
||||
|
||||
do -- testing bug introduced in commit f407b3c4a
|
||||
local X = false -- flag "to be closed"
|
||||
local coro = coroutine.wrap(T.testC)
|
||||
-- runs it until 'pcallk' (that yields)
|
||||
-- 4th argument (at index 4): object to be closed
|
||||
local res1, res2 = coro(
|
||||
[[
|
||||
toclose 3 # this could break the next 'pcallk'
|
||||
pushvalue 2 # push function 'yield' to call it
|
||||
pushint 22; pushint 33 # arguments to yield
|
||||
# calls 'yield' (2 args; 2 results; continuation function at index 4)
|
||||
pcallk 2 2 4
|
||||
invalid command (should not arrive here)
|
||||
]], -- 1st argument (at index 1): code;
|
||||
coroutine.yield, -- (at index 2): function to be called
|
||||
func2close(function () X = true end), -- (index 3): TBC slot
|
||||
"pushint 43; return 3" -- (index 4): code for continuation function
|
||||
)
|
||||
|
||||
assert(res1 == 22 and res2 == 33 and not X)
|
||||
local res1, res2, res3 = coro(34, "hi") -- runs continuation function
|
||||
assert(res1 == 34 and res2 == "hi" and res3 == 43 and X)
|
||||
end
|
||||
|
||||
x = coroutine.wrap(f)
|
||||
assert(x() == 102)
|
||||
eqtab({x()}, {23, "huu"})
|
||||
@@ -1094,11 +1119,11 @@ co = coroutine.wrap(function (...) return
|
||||
cannot be here!
|
||||
]],
|
||||
[[ # 1st continuation
|
||||
yieldk 0 3
|
||||
yieldk 0 3
|
||||
cannot be here!
|
||||
]],
|
||||
[[ # 2nd continuation
|
||||
yieldk 0 4
|
||||
yieldk 0 4
|
||||
cannot be here!
|
||||
]],
|
||||
[[ # 3th continuation
|
||||
|
||||
Reference in New Issue
Block a user