diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-22 10:54:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-22 10:54:25 -0300 |
commit | 0ceada8da92135717d31a3954b5b89a954f9e71a (patch) | |
tree | 99655e44791a11bf805d9f059da7391310618eec /lfunc.c | |
parent | f9d29b0c442447ebe429bcaad1e2b4bf13c5dc93 (diff) | |
download | lua-0ceada8da92135717d31a3954b5b89a954f9e71a.tar.gz lua-0ceada8da92135717d31a3954b5b89a954f9e71a.tar.bz2 lua-0ceada8da92135717d31a3954b5b89a954f9e71a.zip |
Report last error in closing methods
When there are multiple errors around closing methods, report the
last error instead of the original.
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -162,14 +162,10 @@ static int callclosemth (lua_State *L, StkId level, int status) { | |||
162 | luaD_seterrorobj(L, status, level); /* set error message */ | 162 | luaD_seterrorobj(L, status, level); /* set error message */ |
163 | if (prepclosingmethod(L, uv, s2v(level))) { /* something to call? */ | 163 | if (prepclosingmethod(L, uv, s2v(level))) { /* something to call? */ |
164 | int newstatus = luaD_pcall(L, callclose, NULL, oldtop, 0); | 164 | int newstatus = luaD_pcall(L, callclose, NULL, oldtop, 0); |
165 | if (newstatus != LUA_OK && status == CLOSEPROTECT) /* first error? */ | 165 | if (newstatus != LUA_OK) /* new error? */ |
166 | status = newstatus; /* this will be the new error */ | 166 | status = newstatus; /* this will be the error now */ |
167 | else { | 167 | else /* leave original error (or nil) on top */ |
168 | if (newstatus != LUA_OK) /* suppressed error? */ | ||
169 | luaE_warnerror(L, "__close metamethod"); | ||
170 | /* leave original error (or nil) on top */ | ||
171 | L->top = restorestack(L, oldtop); | 168 | L->top = restorestack(L, oldtop); |
172 | } | ||
173 | } | 169 | } |
174 | /* else no metamethod; ignore this case and keep original error */ | 170 | /* else no metamethod; ignore this case and keep original error */ |
175 | } | 171 | } |