From 7c7e1e9b98d4e5dbe7358c795a635c6f1f36f418 Mon Sep 17 00:00:00 2001 From: ii14 Date: Wed, 7 Sep 2022 19:40:17 +0100 Subject: 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 #11075) --- src/dict.c | 6 ++++-- src/testdir/test_listdict.vim | 4 ++++ src/version.c | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dict.c b/src/dict.c index 874b8231da..fa54c60c41 100644 --- a/src/dict.c +++ b/src/dict.c @@ -911,13 +911,15 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) 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; diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index bf3117bbbd..63ba47fabe 100644 --- 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 diff --git a/src/version.c b/src/version.c index c4be8093d2..746852aa19 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 409, /**/ 408, /**/ -- cgit v1.2.3