mirror of
https://github.com/neovim/neovim.git
synced 2026-05-24 05:40:08 +00:00
fix(lua): avoid __index when deciding if a table is a list #39556
Problem: When a table has `__index`, `vim.islist` is unreliable. Solution: Index using `rawget`.
This commit is contained in:
@@ -969,6 +969,17 @@ describe('lua stdlib', function()
|
||||
eq(false, exec_lua('return vim.islist({1, 2, nil, 4})'))
|
||||
eq(false, exec_lua('return vim.islist({nil, 2, 3, 4})'))
|
||||
eq(false, exec_lua('return vim.islist({1, [1.5]=2, [3]=3})'))
|
||||
eq(
|
||||
false,
|
||||
exec_lua([[
|
||||
local t = setmetatable({ 1, [3] = 3 }, {
|
||||
__index = function()
|
||||
return 2
|
||||
end,
|
||||
})
|
||||
return vim.islist(t)
|
||||
]])
|
||||
)
|
||||
end)
|
||||
|
||||
it('vim.tbl_isempty', function()
|
||||
|
||||
Reference in New Issue
Block a user