summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-06 14:14:39 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-06 14:14:39 +0200
commit3cfa5b16b06bcc034f6de77070fa779d698ab5e9 (patch)
tree1791529efb117bb1e68814a35dbe9f6d5a8bca0f /src/json.c
parent7a2217bedd223df4c8bbebe731bf0b5fe8532533 (diff)
downloadvim-git-3cfa5b16b06bcc034f6de77070fa779d698ab5e9.tar.gz
patch 8.2.2949: tests failing because no error for float to string conversionv8.2.2949
Problem: Tests failing because there is no error for float to string conversion. Solution: Change the check for failure to check for correct result. Make some conversions strict in Vim9 script.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c
index db25b70cc..d0a087a92 100644
--- a/src/json.c
+++ b/src/json.c
@@ -607,7 +607,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
cur_item = res;
init_tv(&item);
if (res != NULL)
- init_tv(res);
+ init_tv(res);
fill_numbuflen(reader);
p = reader->js_buf + reader->js_used;
@@ -920,6 +920,15 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
&& cur_item != NULL)
{
+#ifdef FEAT_FLOAT
+ if (cur_item->v_type == VAR_FLOAT)
+ {
+ // cannot use a float as a key
+ emsg(_(e_float_as_string));
+ retval = FAIL;
+ goto theend;
+ }
+#endif
top_item->jd_key = tv_get_string_buf_chk(cur_item, key_buf);
if (top_item->jd_key == NULL)
{