diff --git a/lib/gears/table.lua b/lib/gears/table.lua index 8b9bb6c26..76dff1d37 100644 --- a/lib/gears/table.lua +++ b/lib/gears/table.lua @@ -18,7 +18,8 @@ local gtable = {} -- @return A new table containing all keys from the arguments. function gtable.join(...) local ret = {} - for _, t in ipairs({...}) do + for i = 1, select("#", ...) do + local t = select(i, ...) if t then for k, v in pairs(t) do if type(k) == "number" then diff --git a/spec/gears/table_spec.lua b/spec/gears/table_spec.lua index 435a5b46a..5b69ba0b1 100644 --- a/spec/gears/table_spec.lua +++ b/spec/gears/table_spec.lua @@ -41,4 +41,11 @@ describe("gears.table", function() assert.is.equal(f(), nil) end) end) + + describe("table.join", function() + it("nil argument", function() + local t = gtable.join({"a"}, nil, {"b"}) + assert.is.same(t, {"a", "b"}) + end) + end) end)