aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/json_functions_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-12-06 17:02:13 +0100
committerJustin M. Keyes <justinkz@gmail.com>2023-12-07 12:57:25 +0100
commitcca6c4c6986abc67cd213ad1d32d329384a57790 (patch)
tree7582bde2a49bcd6c171e7a008aef075cb63a5da8 /test/functional/vimscript/json_functions_spec.lua
parent5fa88a7ae13effc02d42070313d3082bf98e22a7 (diff)
downloadrneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.tar.gz
rneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.tar.bz2
rneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.zip
feat(rpc): allow empty string key in msgpack => Vim conversion
Problem: Since e057b38e7037 #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 in 7c01d5ff9286 (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
Diffstat (limited to 'test/functional/vimscript/json_functions_spec.lua')
-rw-r--r--test/functional/vimscript/json_functions_spec.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua
index 53899085e0..c12bcf5099 100644
--- a/test/functional/vimscript/json_functions_spec.lua
+++ b/test/functional/vimscript/json_functions_spec.lua
@@ -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',