aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-15 13:31:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-15 13:31:45 -0300
commitc03c527fd207b4ad8f5a8e0f4f2c176bd227c979 (patch)
tree85f5b692d3e6818ab4bdd21765658c8f0b1fc44b
parent38cc7d40a4bcb89314d212fdffd2ca8deebc3cb7 (diff)
downloadlua-c03c527fd207b4ad8f5a8e0f4f2c176bd227c979.tar.gz
lua-c03c527fd207b4ad8f5a8e0f4f2c176bd227c979.tar.bz2
lua-c03c527fd207b4ad8f5a8e0f4f2c176bd227c979.zip
Bug: 'string.concat' error message uses wrong format
-rw-r--r--ltablib.c2
-rw-r--r--testes/strings.lua3
2 files changed, 4 insertions, 1 deletions
diff --git a/ltablib.c b/ltablib.c
index d344a47e..c7f0e4dc 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -146,7 +146,7 @@ static int tmove (lua_State *L) {
146static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { 146static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {
147 lua_geti(L, 1, i); 147 lua_geti(L, 1, i);
148 if (!lua_isstring(L, -1)) 148 if (!lua_isstring(L, -1))
149 luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", 149 luaL_error(L, "invalid value (%s) at index %I in table for 'concat'",
150 luaL_typename(L, -1), i); 150 luaL_typename(L, -1), i);
151 luaL_addvalue(b); 151 luaL_addvalue(b);
152} 152}
diff --git a/testes/strings.lua b/testes/strings.lua
index 2fa4a89f..61a06a25 100644
--- a/testes/strings.lua
+++ b/testes/strings.lua
@@ -361,6 +361,9 @@ assert(load("return 1\n--comment without ending EOL")() == 1)
361 361
362 362
363checkerror("table expected", table.concat, 3) 363checkerror("table expected", table.concat, 3)
364checkerror("at index " .. maxi, table.concat, {}, " ", maxi, maxi)
365-- '%' escapes following minus signal
366checkerror("at index %" .. mini, table.concat, {}, " ", mini, mini)
364assert(table.concat{} == "") 367assert(table.concat{} == "")
365assert(table.concat({}, 'x') == "") 368assert(table.concat({}, 'x') == "")
366assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2") 369assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2")