Mercurial > vim
changeset 22940:5b2f97d10a8c v8.2.2017
patch 8.2.2017: missing part of the dict change
Commit: https://github.com/vim/vim/commit/67d1c68f095eb6cbb6355b04972e384d23065c2c
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 19 19:01:43 2020 +0100
patch 8.2.2017: missing part of the dict change
Problem: Missing part of the dict change.
Solution: Also change the script level dict.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 19 Nov 2020 19:15:03 +0100 |
parents | 6736887a4ec7 |
children | 2aa5ad6cb21c |
files | src/dict.c src/version.c |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -111,6 +111,7 @@ dict_free_contents(dict_T *d) /* * Clear hashtab "ht" and dict items it contains. + * If "ht" is not freed then you should call hash_init() next! */ void hashtab_free_contents(hashtab_T *ht) @@ -850,10 +851,32 @@ eval_dict(char_u **arg, typval_T *rettv, *arg = skipwhite_and_linebreak(*arg + 1, evalarg); while (**arg != '}' && **arg != NUL) { - if ((literal - ? get_literal_key(arg, &tvkey) - : eval1(arg, &tvkey, evalarg)) == FAIL) // recursive! - goto failret; + char_u *p = to_name_end(*arg, FALSE); + + if (literal || (vim9script && *p == ':')) + { + if (get_literal_key(arg, &tvkey) == FAIL) + goto failret; + } + else + { + int has_bracket = vim9script && **arg == '['; + + if (has_bracket) + *arg = skipwhite(*arg + 1); + if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive! + goto failret; + if (has_bracket) + { + *arg = skipwhite(*arg); + if (**arg != ']') + { + emsg(_(e_missing_matching_bracket_after_dict_key)); + return FAIL; + } + ++*arg; + } + } // the colon should come right after the key, but this wasn't checked // previously, so only require it in Vim9 script.