From b6e350a6b4df40fcc99931c460668c36fadc9989 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 3 Sep 2024 17:14:25 +0100 Subject: fix(lua): allows tables with integer keys to be merged in tbl_deep_extend - The exclusion of lists was never justified in the commit history and is the wrong thing to do for a function that deals with tables. - Move the error checks out of the recursive path. Fixes #23654 --- test/functional/lua/vim_spec.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/functional/lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index df68020d8e..7bba24483e 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1059,7 +1059,7 @@ describe('lua stdlib', function() local a = { a = {[2] = 3} } local b = { a = {[3] = 3} } local c = vim.tbl_deep_extend("force", a, b) - return vim.deep_equal(c, {a = {[3] = 3}}) + return vim.deep_equal(c, {a = {[2] = 3, [3] = 3}}) ]])) eq( @@ -1071,6 +1071,14 @@ describe('lua stdlib', function() ]]) ) + -- Fix github issue #23654 + ok(exec_lua([[ + local a = { sub = { [1] = 'a' } } + local b = { sub = { b = 'a' } } + local c = vim.tbl_deep_extend('force', a, b) + return vim.deep_equal(c, { sub = { [1] = 'a', b = 'a' } }) + ]])) + matches( 'invalid "behavior": nil', pcall_err( -- cgit