From b4d5dff8ec4f1c8a44db66d368e95d359b04aea7 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 5 Jun 2019 13:16:25 -0300 Subject: Multiple errors in '__toclose' report the first one When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback. --- lcorolib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lcorolib.c') diff --git a/lcorolib.c b/lcorolib.c index 156839e6..4d47ea28 100644 --- a/lcorolib.c +++ b/lcorolib.c @@ -75,11 +75,8 @@ static int luaB_auxwrap (lua_State *L) { int r = auxresume(L, co, lua_gettop(L)); if (r < 0) { int stat = lua_status(co); - if (stat != LUA_OK && stat != LUA_YIELD) { - stat = lua_resetthread(co); /* close variables in case of errors */ - if (stat != LUA_OK) /* error closing variables? */ - lua_xmove(co, L, 1); /* get new error object */ - } + if (stat != LUA_OK && stat != LUA_YIELD) + lua_resetthread(co); /* close variables in case of errors */ if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ luaL_where(L, 1); /* add extra info, if available */ lua_insert(L, -2); -- cgit v1.2.3-55-g6feb