Problem: First key in dict is seen as curly expression and fails.
Solution: Ignore failure of curly expression. (closes #9247)
typval_T tv;
char_u *key = NULL;
dictitem_T *item;
- char_u *start = skipwhite(*arg + 1);
+ char_u *curly_expr = skipwhite(*arg + 1);
char_u buf[NUMBUFLEN];
int vim9script = in_vim9script();
int had_comma;
* 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 (!vim9script
+ && *curly_expr != '}'
+ && eval1(&curly_expr, &tv, NULL) == OK
+ && *skipwhite(curly_expr) == '}')
+ return NOTDONE;
if (evaluate)
{
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
: STR2NR_ALL, &n, NULL, 0, TRUE);
if (len == 0)
{
- semsg(_(e_invalid_expression_str), *arg);
+ if (evaluate)
+ semsg(_(e_invalid_expression_str), *arg);
return FAIL;
}
*arg += len;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 3702,
/**/
3701,
/**/