From 4a67f9d386bb16149eecf32f45a3cb73878f12e7 Mon Sep 17 00:00:00 2001 From: ii14 Date: Wed, 7 Sep 2022 20:45:22 +0200 Subject: 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 vim/vim#11075) https://github.com/vim/vim/commit/7c7e1e9b98d4e5dbe7358c795a635c6f1f36f418 --- src/nvim/eval.c | 6 ++++-- src/nvim/testdir/test_listdict.vim | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1171695be3..aa2849279e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4587,12 +4587,14 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) char *curly_expr = skipwhite(*arg + 1); char buf[NUMBUFLEN]; - // 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 (*curly_expr != '}' + && !literal && eval1(&curly_expr, &tv, false) == OK && *skipwhite(curly_expr) == '}') { return NOTDONE; diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index f0440ae14b..9cef6905a5 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -168,6 +168,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 " Dictionary identity -- cgit