forked from aniani/vim
patch 8.2.2066: Vim9: assignment with += doesn't work
Problem: Vim9: assignment with += doesn't work. Solution: Do not see the "+" as an addition operator.
This commit is contained in:
@@ -2769,10 +2769,11 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
int vim9script = in_vim9script();
|
int vim9script = in_vim9script();
|
||||||
|
|
||||||
// "." is only string concatenation when scriptversion is 1
|
// "." is only string concatenation when scriptversion is 1
|
||||||
|
// "+=" and "-=" are assignment
|
||||||
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
op = *p;
|
op = *p;
|
||||||
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
|
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
|
||||||
if (op != '+' && op != '-' && !concat)
|
if ((op != '+' && op != '-' && !concat) || p[1] == '=')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
|
@@ -3332,9 +3332,13 @@ find_ex_command(
|
|||||||
|
|
||||||
// When followed by "=" or "+=" then it is an assignment.
|
// When followed by "=" or "+=" then it is an assignment.
|
||||||
++emsg_silent;
|
++emsg_silent;
|
||||||
if (skip_expr(&after, NULL) == OK
|
if (skip_expr(&after, NULL) == OK)
|
||||||
&& (*after == '='
|
after = skipwhite(after);
|
||||||
|| (*after != NUL && after[1] == '=')))
|
else
|
||||||
|
after = (char_u *)"";
|
||||||
|
if (*after == '=' || (*after != NUL && after[1] == '=')
|
||||||
|
|| (after[0] == '.' && after[1] == '.'
|
||||||
|
&& after[2] == '='))
|
||||||
eap->cmdidx = CMD_var;
|
eap->cmdidx = CMD_var;
|
||||||
else
|
else
|
||||||
eap->cmdidx = CMD_eval;
|
eap->cmdidx = CMD_eval;
|
||||||
|
@@ -866,18 +866,17 @@ def Test_assign_dict_unknown_type()
|
|||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
# doesn't work yet
|
lines =<< trim END
|
||||||
#lines =<< trim END
|
vim9script
|
||||||
# vim9script
|
var mylist = [[]]
|
||||||
# var mylist = [[]]
|
mylist[0] += [#{one: 'one'}]
|
||||||
# mylist[0] += [#{one: 'one'}]
|
def Func()
|
||||||
# def Func()
|
var dd = mylist[0][0]
|
||||||
# var dd = mylist[0][0]
|
assert_equal('one', dd.one)
|
||||||
# assert_equal('one', dd.one)
|
enddef
|
||||||
# enddef
|
Func()
|
||||||
# Func()
|
END
|
||||||
#END
|
CheckScriptSuccess(lines)
|
||||||
#CheckScriptSuccess(lines)
|
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_assign_lambda()
|
def Test_assign_lambda()
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2066,
|
||||||
/**/
|
/**/
|
||||||
2065,
|
2065,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user