Patch 8.2.3702
Problem: First key in dict is seen as curly expression and fails.
Solution: Ignore failure of curly expression. (closes #9247)
Files: src/typval.c, src/dict.c, src/testdir/test_listdict.vim
*** ../vim-8.2.3701/src/typval.c 2021-09-14 16:53:39.320540666 +0100
--- src/typval.c 2021-11-30 11:53:43.879215133 +0000
***************
*** 1822,1828 ****
: STR2NR_ALL, &n, NULL, 0, TRUE);
if (len == 0)
{
! semsg(_(e_invalid_expression_str), *arg);
return FAIL;
}
*arg += len;
--- 1822,1829 ----
: STR2NR_ALL, &n, NULL, 0, TRUE);
if (len == 0)
{
! if (evaluate)
! semsg(_(e_invalid_expression_str), *arg);
return FAIL;
}
*arg += len;
*** ../vim-8.2.3701/src/dict.c 2021-11-22 20:10:14.882598756 +0000
--- src/dict.c 2021-11-30 11:53:24.815244236 +0000
***************
*** 891,897 ****
typval_T tv;
char_u *key = NULL;
dictitem_T *item;
! char_u *start = skipwhite(*arg + 1);
char_u buf[NUMBUFLEN];
int vim9script = in_vim9script();
int had_comma;
--- 891,897 ----
typval_T tv;
char_u *key = NULL;
dictitem_T *item;
! char_u *curly_expr = skipwhite(*arg + 1);
char_u buf[NUMBUFLEN];
int vim9script = in_vim9script();
int had_comma;
***************
*** 903,915 ****
* first item.
* But {} is an empty Dictionary.
*/
! if (!vim9script && *start != '}')
! {
! if (eval1(&start, &tv, NULL) == FAIL) // recursive!
! return FAIL;
! if (*skipwhite(start) == '}')
! return NOTDONE;
! }
if (evaluate)
{
--- 903,913 ----
* first item.
* But {} is an empty Dictionary.
*/
! if (!vim9script
! && *curly_expr != '}'
! && eval1(&curly_expr, &tv, NULL) == OK
! && *skipwhite(curly_expr) == '}')
! return NOTDONE;
if (evaluate)
{
*** ../vim-8.2.3701/src/testdir/test_listdict.vim 2021-11-29
13:44:52.456955927 +0000
--- src/testdir/test_listdict.vim 2021-11-30 11:50:45.663479082 +0000
***************
*** 297,302 ****
--- 297,305 ----
call assert_fails('let d={[] : 10}', 'E730:')
" undefined variable as value
call assert_fails("let d={'k' : i}", 'E121:')
+
+ " allow key starting with number at the start, not a curly expression
+ call assert_equal({'1foo': 77}, #{1foo: 77})
endfunc
" This was allowed in legacy Vim script
*** ../vim-8.2.3701/src/version.c 2021-11-29 22:02:08.108571662 +0000
--- src/version.c 2021-11-30 11:55:46.615023751 +0000
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 3702,
/**/
--
CART DRIVER: Bring out your dead!
We follow the cart through a wretched, impoverished plague-ridden village.
A few starved mongrels run about in the mud scavenging. In the open
doorway of one house perhaps we jug glimpse a pair of legs dangling from
the ceiling. In another doorway an OLD WOMAN is beating a cat against a
wall rather like one does with a mat. The cart passes round a dead donkey
or cow in the mud. And a MAN tied to a cart is being hammered to death by
four NUNS with huge mallets.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211130115753.E5FB71C4FBE%40moolenaar.net.