diff options
-rw-r--r-- | ldo.c | 1 | ||||
-rw-r--r-- | ltests.c | 3 | ||||
-rw-r--r-- | testes/api.lua | 4 |
3 files changed, 8 insertions, 0 deletions
@@ -120,6 +120,7 @@ l_noret luaD_throw (lua_State *L, int errcode) { | |||
120 | else { /* thread has no error handler */ | 120 | else { /* thread has no error handler */ |
121 | global_State *g = G(L); | 121 | global_State *g = G(L); |
122 | errcode = luaE_resetthread(L, errcode); /* close all upvalues */ | 122 | errcode = luaE_resetthread(L, errcode); /* close all upvalues */ |
123 | L->status = errcode; | ||
123 | if (g->mainthread->errorJmp) { /* main thread has a handler? */ | 124 | if (g->mainthread->errorJmp) { /* main thread has a handler? */ |
124 | setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ | 125 | setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ |
125 | luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ | 126 | luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ |
@@ -1655,6 +1655,9 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
1655 | int level = getnum; | 1655 | int level = getnum; |
1656 | luaL_traceback(L1, L1, msg, level); | 1656 | luaL_traceback(L1, L1, msg, level); |
1657 | } | 1657 | } |
1658 | else if EQ("threadstatus") { | ||
1659 | lua_pushstring(L1, statcodes[lua_status(L1)]); | ||
1660 | } | ||
1658 | else if EQ("return") { | 1661 | else if EQ("return") { |
1659 | int n = getnum; | 1662 | int n = getnum; |
1660 | if (L1 != L) { | 1663 | if (L1 != L) { |
diff --git a/testes/api.lua b/testes/api.lua index 752ff18f..eab3059b 100644 --- a/testes/api.lua +++ b/testes/api.lua | |||
@@ -399,6 +399,10 @@ do | |||
399 | -- trivial error | 399 | -- trivial error |
400 | assert(T.checkpanic("pushstring hi; error") == "hi") | 400 | assert(T.checkpanic("pushstring hi; error") == "hi") |
401 | 401 | ||
402 | -- thread status inside panic (bug in 5.4.4) | ||
403 | assert(T.checkpanic("pushstring hi; error", "threadstatus; return 2") == | ||
404 | "ERRRUN") | ||
405 | |||
402 | -- using the stack inside panic | 406 | -- using the stack inside panic |
403 | assert(T.checkpanic("pushstring hi; error;", | 407 | assert(T.checkpanic("pushstring hi; error;", |
404 | [[checkstack 5 XX | 408 | [[checkstack 5 XX |