From 0ceada8da92135717d31a3954b5b89a954f9e71a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 22 Dec 2020 10:54:25 -0300 Subject: Report last error in closing methods When there are multiple errors around closing methods, report the last error instead of the original. --- lfunc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lfunc.c') diff --git a/lfunc.c b/lfunc.c index 6608592b..bfbf270b 100644 --- a/lfunc.c +++ b/lfunc.c @@ -162,14 +162,10 @@ static int callclosemth (lua_State *L, StkId level, int status) { luaD_seterrorobj(L, status, level); /* set error message */ if (prepclosingmethod(L, uv, s2v(level))) { /* something to call? */ int newstatus = luaD_pcall(L, callclose, NULL, oldtop, 0); - if (newstatus != LUA_OK && status == CLOSEPROTECT) /* first error? */ - status = newstatus; /* this will be the new error */ - else { - if (newstatus != LUA_OK) /* suppressed error? */ - luaE_warnerror(L, "__close metamethod"); - /* leave original error (or nil) on top */ + if (newstatus != LUA_OK) /* new error? */ + status = newstatus; /* this will be the error now */ + else /* leave original error (or nil) on top */ L->top = restorestack(L, oldtop); - } } /* else no metamethod; ignore this case and keep original error */ } -- cgit v1.2.3-55-g6feb