From c345877e4c2588324d9a1e5655e8f48200ba2e5e Mon Sep 17 00:00:00 2001 From: Roberto I Date: Wed, 20 Aug 2025 15:29:46 -0300 Subject: Better documentation for LUA_ERRERR Not all errors in a message handler generate a LUA_ERRERR. --- ldo.c | 4 ++-- manual/manual.of | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ldo.c b/ldo.c index f232b588..dff9488e 100644 --- a/ldo.c +++ b/ldo.c @@ -203,7 +203,7 @@ TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { #define ERRORSTACKSIZE (MAXSTACK + STACKERRSPACE) -/* raise an error while running the message handler */ +/* raise a stack error while running the message handler */ l_noret luaD_errerr (lua_State *L) { TString *msg = luaS_newliteral(L, "error in error handling"); setsvalue2s(L, L->top.p, msg); @@ -339,7 +339,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { a stack error; cannot grow further than that. */ lua_assert(stacksize(L) == ERRORSTACKSIZE); if (raiseerror) - luaD_errerr(L); /* error inside message handler */ + luaD_errerr(L); /* stack error inside message handler */ return 0; /* if not 'raiseerror', just signal it */ } else if (n < MAXSTACK) { /* avoids arithmetic overflows */ diff --git a/manual/manual.of b/manual/manual.of index 89e9b8f4..3c704118 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -270,7 +270,7 @@ print(x) --> 10 (the global one) Notice that, in a declaration like @T{local x = x}, the new @id{x} being declared is not in scope yet, -and so the @id{x} in the right-hand side refers to the outside variable. +and so the @id{x} on the right-hand side refers to the outside variable. Because of the @x{lexical scoping} rules, local variables can be freely accessed by functions @@ -2826,7 +2826,16 @@ status codes to indicate different kinds of errors or other conditions: For such errors, Lua does not call the @x{message handler}. } -@item{@defid{LUA_ERRERR}| error while running the @x{message handler}.} +@item{@defid{LUA_ERRERR}| +stack overflow while running the @x{message handler} +due to another stack overflow. +More often than not, +this error is the result of some other error while running +a message handler. +An error in a message handler will call the handler again, +which will generate the error again, and so on, +until this loop exhausts the stack and cause this error. +} @item{@defid{LUA_ERRSYNTAX}| syntax error during precompilation or format error in a binary chunk.} -- cgit v1.2.3-55-g6feb