Mercurial > vim
changeset 30146:d58afefecd6c v9.0.0409
patch 9.0.0409: #{g:x} was seen as a curly-braces expression
Commit: https://github.com/vim/vim/commit/7c7e1e9b98d4e5dbe7358c795a635c6f1f36f418
Author: ii14 <ii14@users.noreply.github.com>
Date: Wed Sep 7 19:40:17 2022 +0100
patch 9.0.0409: #{g:x} was seen as a curly-braces expression
Problem: #{g:x} was seen as a curly-braces expression.
Solution: Do never see #{} as a curly-braces expression. (closes https://github.com/vim/vim/issues/11075)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 07 Sep 2022 20:45:03 +0200 |
parents | 7571004d6f37 |
children | eae31105c82b |
files | src/dict.c src/testdir/test_listdict.vim src/version.c |
diffstat | 3 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -911,13 +911,15 @@ eval_dict(char_u **arg, typval_T *rettv, int vim9script = in_vim9script(); int had_comma; - // First check if it's not a curly-braces thing: {expr}. + // First check if it's not a curly-braces expression: {expr}. // Must do this without evaluating, otherwise a function may be called // twice. Unfortunately this means we need to call eval1() twice for the // first item. - // But {} is an empty Dictionary. + // "{}" is an empty Dictionary. + // "#{abc}" is never a curly-braces expression. if (!vim9script && *curly_expr != '}' + && !literal && eval1(&curly_expr, &tv, NULL) == OK && *skipwhite(curly_expr) == '}') return NOTDONE;
--- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -321,6 +321,10 @@ func Test_dict() " allow key starting with number at the start, not a curly expression call assert_equal({'1foo': 77}, #{1foo: 77}) + + " #{expr} is not a curly expression + let x = 'x' + call assert_equal(#{g: x}, #{g:x}) endfunc " This was allowed in legacy Vim script