'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:
Roberto Ierusalimschy
2020-12-18 11:22:42 -03:00
parent b17178b27a
commit 409256b784
5 changed files with 40 additions and 15 deletions

View File

@@ -4098,10 +4098,12 @@ and then pops the top element.
Resets a thread, cleaning its call stack and closing all pending
to-be-closed variables.
Returns a status code:
@Lid{LUA_OK} for no errors in closing methods,
@Lid{LUA_OK} for no errors in the thread
(either the original error that stopped the thread or
errors in closing methods),
or an error status otherwise.
In case of error,
leaves the error object on the top of the stack,
leaves the error object on the top of the stack.
}
@@ -6577,7 +6579,9 @@ that is,
closes all its pending to-be-closed variables
and puts the coroutine in a dead state.
The given coroutine must be dead or suspended.
In case of error closing some variable,
In case of error
(either the original error that stopped the coroutine or
errors in closing methods),
returns @false plus the error object;
otherwise returns @true.