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:
Roberto Ierusalimschy
2018-12-10 13:46:03 -02:00
parent 28d829c867
commit 46beca5bed
7 changed files with 41 additions and 12 deletions

View File

@@ -20,7 +20,7 @@
static lua_State *getco (lua_State *L) {
lua_State *co = lua_tothread(L, 1);
luaL_argcheck(L, co, 1, "thread expected");
luaL_argexpected(L, co, 1, "thread");
return co;
}