Complete implementation of to-be-closed variables

This commit is contained in:
Roberto Ierusalimschy
2018-10-22 14:55:51 -03:00
parent 3c7dc52909
commit c90176f969
3 changed files with 39 additions and 12 deletions

View File

@@ -734,19 +734,18 @@ a, b = coroutine.resume(co, 100)
assert(a and b == 30)
-- check traceback of suspended (or dead with error) coroutines
-- check traceback of suspended coroutines
function f(i) if i==0 then error(i) else coroutine.yield(); f(i-1) end end
function f(i) coroutine.yield(i == 0); f(i - 1) end
co = coroutine.create(function (x) f(x) end)
a, b = coroutine.resume(co, 3)
t = {"'coroutine.yield'", "'f'", "in function <"}
while coroutine.status(co) == "suspended" do
repeat
checktraceback(co, t)
a, b = coroutine.resume(co)
table.insert(t, 2, "'f'") -- one more recursive call to 'f'
end
t[1] = "'error'"
until b
checktraceback(co, t)