mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
'coroutine.close'/'lua_resetthread' report original errors
Besides errors in closing methods, 'coroutine.close' and 'lua_resetthread' also consider the original error that stopped the thread, if any.
This commit is contained in:
parent
b17178b27a
commit
409256b784
5 changed files with 40 additions and 15 deletions
|
|
@ -135,14 +135,18 @@ if T then
|
|||
local topB, sizeB -- top and size Before overflow
|
||||
local topA, sizeA -- top and size After overflow
|
||||
topB, sizeB = T.stacklevel()
|
||||
collectgarbage("stop") -- __gc should not be called with a full stack
|
||||
xpcall(f, err)
|
||||
collectgarbage("restart")
|
||||
topA, sizeA = T.stacklevel()
|
||||
-- sizes should be comparable
|
||||
assert(topA == topB and sizeA < sizeB * 2)
|
||||
print(string.format("maximum stack size: %d", stack1))
|
||||
LIM = N -- will stop recursion at maximum level
|
||||
N = 0 -- to count again
|
||||
collectgarbage("stop") -- __gc should not be called with a full stack
|
||||
f()
|
||||
collectgarbage("restart")
|
||||
print"+"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue