From 0ceada8da92135717d31a3954b5b89a954f9e71a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> 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. --- lcorolib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lcorolib.c') diff --git a/lcorolib.c b/lcorolib.c index c165031d..ed7c58b2 100644 --- a/lcorolib.c +++ b/lcorolib.c @@ -75,8 +75,11 @@ static int luaB_auxwrap (lua_State *L) { int r = auxresume(L, co, lua_gettop(L)); if (r < 0) { /* error? */ int stat = lua_status(co); - if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */ - lua_resetthread(co); /* close its tbc variables */ + if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ + stat = lua_resetthread(co); /* close its tbc variables */ + lua_assert(stat != LUA_OK); + lua_xmove(co, L, 1); /* copy error message */ + } if (stat != LUA_ERRMEM && /* not a memory error and ... */ lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ luaL_where(L, 1); /* add extra info, if available */ -- cgit v1.2.3-55-g6feb