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
This commit is contained in:
Lewis Russell
2024-09-03 17:14:25 +01:00
committed by Lewis Russell
parent 7b7c95dac9
commit b6e350a6b4
3 changed files with 42 additions and 24 deletions

View File

@@ -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(