diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-10 13:46:03 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-10 13:46:03 -0200 |
commit | 46beca5bed8a7700b18100fe48a78373be5055f9 (patch) | |
tree | 499de35c048605434d9adb7ace964adf673041ac /lstrlib.c | |
parent | 28d829c86712ce5bc453feccc5129a32f78d80c0 (diff) | |
download | lua-46beca5bed8a7700b18100fe48a78373be5055f9.tar.gz lua-46beca5bed8a7700b18100fe48a78373be5055f9.tar.bz2 lua-46beca5bed8a7700b18100fe48a78373be5055f9.zip |
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...)
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -857,9 +857,9 @@ static int str_gsub (lua_State *L) { | |||
857 | lua_Integer n = 0; /* replacement count */ | 857 | lua_Integer n = 0; /* replacement count */ |
858 | MatchState ms; | 858 | MatchState ms; |
859 | luaL_Buffer b; | 859 | luaL_Buffer b; |
860 | luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || | 860 | luaL_argexpected(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || |
861 | tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, | 861 | tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, |
862 | "string/function/table expected"); | 862 | "string/function/table"); |
863 | luaL_buffinit(L, &b); | 863 | luaL_buffinit(L, &b); |
864 | if (anchor) { | 864 | if (anchor) { |
865 | p++; lp--; /* skip anchor character */ | 865 | p++; lp--; /* skip anchor character */ |