]> granicus.if.org Git - vim/commitdiff
patch 9.0.0409: #{g:x} was seen as a curly-braces expression v9.0.0409
authorii14 <ii14@users.noreply.github.com>
Wed, 7 Sep 2022 18:40:17 +0000 (19:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Sep 2022 18:40:17 +0000 (19:40 +0100)
Problem:    #{g:x} was seen as a curly-braces expression.
Solution:   Do never see #{} as a curly-braces expression. (closes #11075)

src/dict.c
src/testdir/test_listdict.vim
src/version.c

index 874b8231da009414a0083f7365ee99eac86e3920..fa54c60c417aedd5844441ecce204a91406a8a94 100644 (file)
@@ -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;
index bf3117bbbd3020d40dc054579b6b0d2e2d5886a0..63ba47fabe1d07d6c3630a69b13b6cb1b845749c 100644 (file)
@@ -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
index c4be8093d22797bb0cdefb4de1e4f60b89eac69e..746852aa198775aec653e9780b73143fba159e9e 100644 (file)
@@ -703,6 +703,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    409,
 /**/
     408,
 /**/