Skip to content

Commit dbb0540

Browse files
committed
Ignore extra args in table.extend(t1, t2) calls
1 parent 36568d2 commit dbb0540

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

VM/src/ltablib.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,14 @@ static int tappend(lua_State* L)
263263
// so it makes sense to provide as a first-class member of the stdlib.
264264
static int textend(lua_State* L)
265265
{
266-
lua_checkstack(L, 6);
267-
268266
luaL_checktype(L, 1, LUA_TTABLE);
269267
luaL_checktype(L, 2, LUA_TTABLE);
268+
269+
// ignore further arguments
270+
lua_settop(L, 2);
271+
272+
lua_checkstack(L, 6);
273+
270274
int dn = lua_objlen(L, 1);
271275
int sn = lua_objlen(L, 2);
272276

tests/conformance/tables.luau

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,11 @@ do
860860
-- Returns destination table
861861
local t6 = {1, 2}
862862
assert(table.extend(t6, {3, 4}) == t6)
863+
864+
-- Extra args ignored
865+
local t7 = {1, 2}
866+
assert(table.extend(t7, {3,4}, {5,6}, {7,8}) == t7)
867+
assert(table.concat(t7, ',') == "1,2,3,4")
863868
end
864869

865-
return"OK"
870+
return "OK"

0 commit comments

Comments
 (0)