Allow yields inside '__close' metamethods

Initial implementation to allow yields inside '__close' metamethods.
This current version still does not allow a '__close' metamethod
to yield when called due to an error. '__close' metamethods from
C functions also are not allowed to yield.
This commit is contained in:
Roberto Ierusalimschy
2021-01-13 13:54:10 -03:00
parent cc1692515e
commit b07fc10e91
7 changed files with 114 additions and 18 deletions

4
lapi.c
View File

@@ -189,7 +189,7 @@ LUA_API void lua_settop (lua_State *L, int idx) {
}
#if defined(LUA_COMPAT_5_4_0)
if (diff < 0 && hastocloseCfunc(ci->nresults))
luaF_close(L, L->top + diff, CLOSEKTOP);
luaF_close(L, L->top + diff, CLOSEKTOP, 0);
#endif
L->top += diff;
api_check(L, L->openupval == NULL || uplevel(L->openupval) < L->top,
@@ -205,7 +205,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
api_check(L, hastocloseCfunc(L->ci->nresults) && L->openupval != NULL &&
uplevel(L->openupval) == level,
"no variable to close at given level");
luaF_close(L, level, CLOSEKTOP);
luaF_close(L, level, CLOSEKTOP, 0);
setnilvalue(s2v(level));
lua_unlock(L);
}