better error message for 'concat'

This commit is contained in:
Roberto Ierusalimschy 2007-09-12 17:53:24 -03:00
parent fe0838cd1c
commit 80b4753539

View File

@ -1,5 +1,5 @@
/*
** $Id: ltablib.c,v 1.39 2007/06/21 13:48:04 roberto Exp roberto $
** $Id: ltablib.c,v 1.40 2007/06/21 13:50:53 roberto Exp roberto $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@ -133,7 +133,9 @@ static int tconcat (lua_State *L) {
luaL_buffinit(L, &b);
for (; i <= last; i++) {
lua_rawgeti(L, 1, i);
luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings");
if (!lua_isstring(L, -1))
return luaL_error(L, "invalid value (%s) at index %d in table for "
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_addvalue(&b);
if (i != last)
luaL_addlstring(&b, sep, lsep);