From fd897027f19288ce2cb0249cb8c1818e2f3f1c4c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 12 Jun 2025 11:15:09 -0300 Subject: A coroutine can close itself A call to close itself will close all its to-be-closed variables and return to the resume that (re)started the coroutine. --- lstate.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 20ed838f..70a11aae 100644 --- a/lstate.c +++ b/lstate.c @@ -326,6 +326,8 @@ LUA_API int lua_closethread (lua_State *L, lua_State *from) { lua_lock(L); L->nCcalls = (from) ? getCcalls(from) : 0; status = luaE_resetthread(L, L->status); + if (L == from) /* closing itself? */ + luaD_throwbaselevel(L, status); lua_unlock(L); return APIstatus(status); } -- cgit v1.2.3-55-g6feb