Mercurial > vim
diff src/json.c @ 24822:5f8dd7b3ae41 v8.2.2949
patch 8.2.2949: tests failing because no error for float to string conversion
Commit: https://github.com/vim/vim/commit/3cfa5b16b06bcc034f6de77070fa779d698ab5e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 6 14:14:39 2021 +0200
patch 8.2.2949: tests failing because no error for float to string conversion
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 06 Jun 2021 14:15:04 +0200 |
parents | 661d15592d3c |
children | e8e2c4d33b9b |
line wrap: on
line diff
--- a/src/json.c +++ b/src/json.c @@ -607,7 +607,7 @@ json_decode_item(js_read_T *reader, typv 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, typv 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) {