lua-users home
lua-l archive

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


checkout 
https://github.com/ignacio/StackTracePlus





---- Em Sáb, 04 nov 2023 06:16:15 -0300 Iurii Belobeev <marsgpl@gmail.com> escreveu ---

Hi,

I have this code:

lua_getglobal(L, "mytable");
lua_getfield(L, -1, "myfunc");
lua_pushboolean(L, 1);
lua_call(L, 1, 0);

and I have this check inside myfunc:

luaL_checktype(L, 1, LUA_TFUNCTION);

I intentionally receive this error:
bad argument #1 to '?' (function expected, got boolean)

I want to find a way to provide a name for my function and have it
printed instead of '?'.

I look at luaL_argerror, and I see that it calls lua_getinfo() which
fills lua_Debug ar.name (which is used as function name).
So ar.name is NULL in my case (I checked).
I believe it would take an unpredictable time for me to analyze the
lua_getinfo code, so maybe somebody knows, how should I provide a
function name?