Better error messages for some polymorphic functions
New auxiliary functions/macros 'luaL_argexpected'/'luaL_typeerror' ease the creation of error messages such as bad argument #2 to 'setmetatable' (nil or table expected, got boolean) (The novelty being the "got boolean" part...)
This commit is contained in:
@@ -857,9 +857,9 @@ static int str_gsub (lua_State *L) {
|
||||
lua_Integer n = 0; /* replacement count */
|
||||
MatchState ms;
|
||||
luaL_Buffer b;
|
||||
luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
|
||||
luaL_argexpected(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
|
||||
tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
|
||||
"string/function/table expected");
|
||||
"string/function/table");
|
||||
luaL_buffinit(L, &b);
|
||||
if (anchor) {
|
||||
p++; lp--; /* skip anchor character */
|
||||
|
||||
Reference in New Issue
Block a user