From c03c527fd207b4ad8f5a8e0f4f2c176bd227c979 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 15 Feb 2021 13:31:45 -0300 Subject: Bug: 'string.concat' error message uses wrong format --- ltablib.c | 2 +- testes/strings.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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) { static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { lua_geti(L, 1, i); if (!lua_isstring(L, -1)) - luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", + luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", luaL_typename(L, -1), i); luaL_addvalue(b); } 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) checkerror("table expected", table.concat, 3) +checkerror("at index " .. maxi, table.concat, {}, " ", maxi, maxi) +-- '%' escapes following minus signal +checkerror("at index %" .. mini, table.concat, {}, " ", mini, mini) assert(table.concat{} == "") assert(table.concat({}, 'x') == "") assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2") -- cgit v1.2.3-55-g6feb