Skip to content

Commit 7c7e1e9

Browse files
ii14brammool
authored andcommitted
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)
1 parent fef38d8 commit 7c7e1e9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/dict.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,13 +911,15 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
911911
int vim9script = in_vim9script();
912912
int had_comma;
913913

914-
// First check if it's not a curly-braces thing: {expr}.
914+
// First check if it's not a curly-braces expression: {expr}.
915915
// Must do this without evaluating, otherwise a function may be called
916916
// twice. Unfortunately this means we need to call eval1() twice for the
917917
// first item.
918-
// But {} is an empty Dictionary.
918+
// "{}" is an empty Dictionary.
919+
// "#{abc}" is never a curly-braces expression.
919920
if (!vim9script
920921
&& *curly_expr != '}'
922+
&& !literal
921923
&& eval1(&curly_expr, &tv, NULL) == OK
922924
&& *skipwhite(curly_expr) == '}')
923925
return NOTDONE;

src/testdir/test_listdict.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ func Test_dict()
321321

322322
" allow key starting with number at the start, not a curly expression
323323
call assert_equal({'1foo': 77}, #{1foo: 77})
324+
325+
" #{expr} is not a curly expression
326+
let x = 'x'
327+
call assert_equal(#{g: x}, #{g:x})
324328
endfunc
325329

326330
" This was allowed in legacy Vim script

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
409,
706708
/**/
707709
408,
708710
/**/

0 commit comments

Comments
 (0)