fix(shared): avoid indexing unindexable values in vim.tbl_get()

This commit is contained in:
William Boman
2022-05-01 01:08:10 +02:00
parent cc27540560
commit 95ec38dc8d
2 changed files with 6 additions and 1 deletions

View File

@@ -492,6 +492,8 @@ describe('lua stdlib', function()
it('vim.tbl_get', function()
eq(true, exec_lua("return vim.tbl_get({ test = { nested_test = true }}, 'test', 'nested_test')"))
eq(NIL, exec_lua("return vim.tbl_get({ unindexable = true }, 'unindexable', 'missing_key')"))
eq(NIL, exec_lua("return vim.tbl_get({ unindexable = 1 }, 'unindexable', 'missing_key')"))
eq(NIL, exec_lua("return vim.tbl_get({}, 'missing_key')"))
eq(NIL, exec_lua("return vim.tbl_get({})"))
end)