@@ -1541,23 +1541,30 @@ if there was no error, the second argument is @nil.
15411541
15421542If several to-be-closed variables go out of scope at the same event,
15431543they are closed in the reverse order that they were declared.
1544+
15441545If there is any error while running a closing method,
15451546that error is handled like an error in the regular code
15461547where the variable was defined;
15471548in particular,
15481549the other pending closing methods will still be called.
1550+ After an error,
1551+ other errors in closing methods
1552+ interrupt the respective method,
1553+ but are otherwise ignored;
1554+ the error reported is the original one.
15491555
15501556If a coroutine yields inside a block and is never resumed again,
15511557the variables visible at that block will never go out of scope,
15521558and therefore they will never be closed.
15531559Similarly, if a coroutine ends with an error,
15541560it does not unwind its stack,
15551561so it does not close any variable.
1556- You should either use finalizers
1557- or call @Lid{coroutine.close} to close the variables in these cases.
1558- However, note that if the coroutine was created
1562+ In both cases,
1563+ you should either use finalizers
1564+ or call @Lid{coroutine.close} to close the variables.
1565+ However, if the coroutine was created
15591566through @Lid{coroutine.wrap},
1560- then its corresponding function will close all variables
1567+ then its corresponding function will close the coroutine
15611568in case of errors.
15621569
15631570}
@@ -3932,7 +3939,7 @@ Returns a status code:
39323939@Lid{LUA_OK} for no errors in closing methods,
39333940or an error status otherwise.
39343941In case of error,
3935- leave the error object on the stack,
3942+ leaves the error object on the top of the stack,
39363943
39373944}
39383945
@@ -6355,6 +6362,7 @@ Closes coroutine @id{co},
63556362that is,
63566363closes all its pending to-be-closed variables
63576364and puts the coroutine in a dead state.
6365+ The given coroutine must be dead or suspended.
63586366In case of error closing some variable,
63596367returns @false plus the error object;
63606368otherwise returns @true.
@@ -6412,7 +6420,8 @@ true when the running coroutine is the main one.
64126420
64136421Returns the status of the coroutine @id{co}, as a string:
64146422@T{"running"},
6415- if the coroutine is running (that is, it called @id{status});
6423+ if the coroutine is running
6424+ (that is, it is the one that called @id{status});
64166425@T{"suspended"}, if the coroutine is suspended in a call to @id{yield},
64176426or if it has not started running yet;
64186427@T{"normal"} if the coroutine is active but not running
0 commit comments