'__close' gets no error object if there is no error

Instead of receiving nil as a second argument, __close metamethods are
called with just one argument when there are no errors.
This commit is contained in:
Roberto Ierusalimschy
2025-02-28 10:10:27 -03:00
parent f9e35627ed
commit 127a8e80fe
4 changed files with 60 additions and 27 deletions

4
ldo.c
View File

@@ -111,10 +111,6 @@ void luaD_seterrorobj (lua_State *L, TStatus errcode, StkId oldtop) {
setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
break;
}
case LUA_OK: { /* special case only for closing upvalues */
setnilvalue(s2v(oldtop)); /* no error message */
break;
}
default: {
lua_assert(errorstatus(errcode)); /* real error */
setobjs2s(L, oldtop, L->top.p - 1); /* error message on current top */