mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
feat(rpc): allow empty string key in msgpack => Vim conversion
Problem: Sincee057b38e70
#20757 we support empty key in JSON encode/decode, but we don't allow it in RPC object => Vim dict conversion. But empty string is a valid key in Vim dicts and the msgpack spec. Empty string key was disallowed in7c01d5ff92
(2014) but that commit/PR doesn't explicitly discuss it, so presumably it was a "seems reasonable" decision (or Vimscript didn't allow empty keys until later). Solution: Remove the check in `object_to_vim()`. Note that `tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed by the C spec: https://stackoverflow.com/a/3751937/152142
This commit is contained in:
@@ -576,8 +576,8 @@ describe('json_encode() function', function()
|
||||
eq('{}', eval('json_encode({})'))
|
||||
eq('{"d": []}', funcs.json_encode({d={}}))
|
||||
eq('{"d": [], "e": []}', funcs.json_encode({d={}, e={}}))
|
||||
-- Empty keys not allowed (yet?) in object_to_vim() (since 7c01d5ff9286). #25564
|
||||
-- eq('{"": []}', funcs.json_encode({['']={}}))
|
||||
-- Empty keys are allowed per JSON spec (and Vim dicts, and msgpack).
|
||||
eq('{"": []}', funcs.json_encode({['']={}}))
|
||||
end)
|
||||
|
||||
it('cannot dump generic mapping with generic mapping keys and values',
|
||||
|
Reference in New Issue
Block a user