debugging message assumes that method calls ("x:y()") have an initial

self argument; we remove it, causing off-by-one error messages
This commit is contained in:
Glenn Maynard
2005-05-28 07:27:49 +00:00
parent 25f5102325
commit e504164796
3 changed files with 26 additions and 7 deletions
+11
View File
@@ -379,6 +379,17 @@ void LuaManager::Fail( const CString &err )
lua_error( L );
}
/* Like luaL_typerror, but without the special case for argument 1 being "self"
* in method calls, so we give a correct error message after we remove self. */
int LuaHelpers::TypeError( int iArgNo, const char *szName )
{
lua_Debug debug;
lua_getstack( LUA->L, 0, &debug );
lua_getinfo( LUA->L, "n", &debug );
return luaL_error( LUA->L, "bad argument #%d to \"%s\" (%s expected, got %s)",
iArgNo, debug.name? debug.name:"(unknown)", szName, lua_typename(LUA->L, lua_type(LUA->L, iArgNo)) );
}
LuaFunctionList::LuaFunctionList( CString name_, lua_CFunction func_ )
{