1
0
forked from aniani/vim

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)
This commit is contained in:
ii14
2022-09-07 19:40:17 +01:00
committed by Bram Moolenaar
parent fef38d86a1
commit 7c7e1e9b98
3 changed files with 10 additions and 2 deletions

View File

@@ -911,13 +911,15 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
int vim9script = in_vim9script(); int vim9script = in_vim9script();
int had_comma; 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 // Must do this without evaluating, otherwise a function may be called
// twice. Unfortunately this means we need to call eval1() twice for the // twice. Unfortunately this means we need to call eval1() twice for the
// first item. // first item.
// But {} is an empty Dictionary. // "{}" is an empty Dictionary.
// "#{abc}" is never a curly-braces expression.
if (!vim9script if (!vim9script
&& *curly_expr != '}' && *curly_expr != '}'
&& !literal
&& eval1(&curly_expr, &tv, NULL) == OK && eval1(&curly_expr, &tv, NULL) == OK
&& *skipwhite(curly_expr) == '}') && *skipwhite(curly_expr) == '}')
return NOTDONE; return NOTDONE;

View File

@@ -321,6 +321,10 @@ func Test_dict()
" allow key starting with number at the start, not a curly expression " allow key starting with number at the start, not a curly expression
call assert_equal({'1foo': 77}, #{1foo: 77}) call assert_equal({'1foo': 77}, #{1foo: 77})
" #{expr} is not a curly expression
let x = 'x'
call assert_equal(#{g: x}, #{g:x})
endfunc endfunc
" This was allowed in legacy Vim script " This was allowed in legacy Vim script

View File

@@ -703,6 +703,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
409,
/**/ /**/
408, 408,
/**/ /**/