mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 21:30:34 +00:00
Merge pull request #40475 from bfredl/vim.NIL
fix(lua): give nicer error message when trying to index vim.NIL
This commit is contained in:
@@ -178,6 +178,13 @@ describe('vim.json.decode()', function()
|
||||
pcall_err(exec_lua, [[return vim.json.decode('{"a":1/*x*/0}', { skip_comments = true })]])
|
||||
)
|
||||
end)
|
||||
|
||||
it('gives nice error message when attempting to index into null value', function()
|
||||
exec_lua [[ parsed = vim.json.decode('{"foo": null}') ]]
|
||||
|
||||
eq('attempt to index vim.NIL', pcall_err(exec_lua, [[ return parsed.foo.sub_field ]]))
|
||||
eq('attempt to index vim.NIL', pcall_err(exec_lua, [[ parsed.foo.new_field = 3 ]]))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.json.encode()', function()
|
||||
|
||||
Reference in New Issue
Block a user