diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-22 14:55:51 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-22 14:55:51 -0300 |
commit | c90176f96924ee7d207501b32f216925773d3bdb (patch) | |
tree | 234f3aefb0617dd7e3d1ff5faf32f9fbdf96c2d7 /ldo.c | |
parent | 3c7dc52909ce0688bdb20cacaf686413a79aaf48 (diff) | |
download | lua-github-scopedvars.tar.gz |
Complete implementation of to-be-closed variablesscopedvars
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -676,12 +676,15 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, /* unroll continuation */ status = luaD_rawrunprotected(L, unroll, &status); } - if (unlikely(errorstatus(status))) { /* unrecoverable error? */ + if (likely(!errorstatus(status))) + lua_assert(status == L->status); /* normal end or yield */ + else { /* unrecoverable error */ + status = luaF_close(L, L->stack, status); /* close all upvalues */ L->status = cast_byte(status); /* mark thread as 'dead' */ - luaD_seterrorobj(L, status, L->top); /* push error message */ + luaD_seterrorobj(L, status, L->stack + 1); /* push error message */ + L->ci = &L->base_ci; /* back to the original C level */ L->ci->top = L->top; } - else lua_assert(status == L->status); /* normal end or yield */ } *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield : cast_int(L->top - (L->ci->func + 1)); |