2
0
Эх сурвалжийг харах

Bug: 'string.concat' error message uses wrong format

Roberto Ierusalimschy 4 жил өмнө
parent
commit
c03c527fd2
2 өөрчлөгдсөн 4 нэмэгдсэн , 1 устгасан
  1. 1 1
      ltablib.c
  2. 3 0
      testes/strings.lua

+ 1 - 1
ltablib.c

@@ -146,7 +146,7 @@ static int tmove (lua_State *L) {
 static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {
 static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {
   lua_geti(L, 1, i);
   lua_geti(L, 1, i);
   if (!lua_isstring(L, -1))
   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_typename(L, -1), i);
   luaL_addvalue(b);
   luaL_addvalue(b);
 }
 }

+ 3 - 0
testes/strings.lua

@@ -361,6 +361,9 @@ assert(load("return 1\n--comment without ending EOL")() == 1)
 
 
 
 
 checkerror("table expected", table.concat, 3)
 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{} == "")
 assert(table.concat({}, 'x') == "")
 assert(table.concat({}, 'x') == "")
 assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2")
 assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2")