lua-users home
lua-l archive

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


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 (which is used as function name).
So 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?