lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was good to hear that this will be addressed in the next version.

In the meantime, the following appears to work; no warranties, do not use under the influence of heavy machinery, etc.

In ldebug.c, replace the definition of luaG_errormsg with the following:

 void luaG_errormsg (lua_State *L) {
   const TObject *errfunc;
   if (L->errfunc != 0) {  /* is there an error handling function? */
     errfunc = restorestack(L, L->errfunc);
  } else {
    errfunc = luaH_getstr(hvalue(gt(L)), luaS_new(L, "_TRACEBACK"));
  if (ttisfunction(errfunc)) {
    setobjs2s(L->top, L->top - 1);  /* move argument */
    setobj2s(L->top - 1, errfunc);  /* push function */
    luaD_call(L, L->top - 2, 1);  /* call it */
  luaD_throw(L, LUA_ERRRUN);

Of course, all this does is generate a traceback; it is still necessary to check the return from coroutine.resume/lua_resume.