aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-10 13:46:03 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-10 13:46:03 -0200
commit46beca5bed8a7700b18100fe48a78373be5055f9 (patch)
tree499de35c048605434d9adb7ace964adf673041ac /lstrlib.c
parent28d829c86712ce5bc453feccc5129a32f78d80c0 (diff)
downloadlua-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lstrlib.c b/lstrlib.c
index a635e9d4..e9c60c0f 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -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 */