Patch 9.0.0409

2 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 7, 2022, 3:02:46 PM9/7/22
to vim...@googlegroups.com

Patch 9.0.0409
Problem: #{g:x} was seen as a curly-braces expression.
Solution: Do never see #{} as a curly-braces expression. (closes #11075)
Files: src/dict.c, src/testdir/test_listdict.vim


*** ../vim-9.0.0408/src/dict.c 2022-08-30 19:48:17.198760230 +0100
--- src/dict.c 2022-09-07 19:39:25.622566867 +0100
***************
*** 911,923 ****
int vim9script = in_vim9script();
int had_comma;

! // First check if it's not a curly-braces thing: {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.
if (!vim9script
&& *curly_expr != '}'
&& eval1(&curly_expr, &tv, NULL) == OK
&& *skipwhite(curly_expr) == '}')
return NOTDONE;
--- 911,925 ----
int vim9script = in_vim9script();
int had_comma;

! // 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.
! // "{}" 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;
*** ../vim-9.0.0408/src/testdir/test_listdict.vim 2022-09-02 15:15:11.063569185 +0100
--- src/testdir/test_listdict.vim 2022-09-07 19:36:19.399196301 +0100
***************
*** 321,326 ****
--- 321,330 ----

" 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
*** ../vim-9.0.0408/src/version.c 2022-09-07 19:03:37.204182098 +0100
--- src/version.c 2022-09-07 19:39:52.674481081 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 409,
/**/

--
I have a drinking problem -- I can't afford it.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages