Bug: Missing error status in panic function

'luaD_throw' may call 'luaE_resetthread', which returns an error code
but clears 'L->status'; so, 'luaD_throw' should set that status again.
diff --git a/ldo.c b/ldo.c
index ea05295..958b1b7 100644
--- a/ldo.c
+++ b/ldo.c
@@ -120,6 +120,7 @@
   else {  /* thread has no error handler */
     global_State *g = G(L);
     errcode = luaE_resetthread(L, errcode);  /* close all upvalues */
+    L->status = errcode;
     if (g->mainthread->errorJmp) {  /* main thread has a handler? */
       setobjs2s(L, g->mainthread->top.p++, L->top.p - 1);  /* copy error obj. */
       luaD_throw(g->mainthread, errcode);  /* re-throw in main thread */
diff --git a/ltests.c b/ltests.c
index a27cdb0..af0f43e 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1655,6 +1655,9 @@
       int level = getnum;
       luaL_traceback(L1, L1, msg, level);
     }
+    else if EQ("threadstatus") {
+      lua_pushstring(L1, statcodes[lua_status(L1)]);
+    }
     else if EQ("return") {
       int n = getnum;
       if (L1 != L) {
diff --git a/testes/api.lua b/testes/api.lua
index 752ff18..eab3059 100644
--- a/testes/api.lua
+++ b/testes/api.lua
@@ -399,6 +399,10 @@
   -- trivial error
   assert(T.checkpanic("pushstring hi; error") == "hi")
 
+ -- thread status inside panic (bug in 5.4.4)
+  assert(T.checkpanic("pushstring hi; error", "threadstatus; return 2") ==
+         "ERRRUN")
+
   -- using the stack inside panic
   assert(T.checkpanic("pushstring hi; error;",
     [[checkstack 5 XX