Better error messages for calling non-callable objects

When available, use the calling code to find a suitable name for what
was being called; this is particularly useful for errors of non-callable
metamethods. This commit also improved the debug information for
order metamethods.
This commit is contained in:
Roberto Ierusalimschy
2020-12-29 13:15:54 -03:00
parent 59e565d955
commit 4bd10b6fe8
6 changed files with 52 additions and 11 deletions

2
ldo.c
View File

@@ -372,7 +372,7 @@ void luaD_tryfuncTM (lua_State *L, StkId func) {
const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
StkId p;
if (unlikely(ttisnil(tm)))
luaG_typeerror(L, s2v(func), "call"); /* nothing to call */
luaG_callerror(L, s2v(func)); /* nothing to call */
for (p = L->top; p > func; p--) /* open space for metamethod */
setobjs2s(L, p, p-1);
L->top++; /* stack space pre-allocated by the caller */