Skip to content

Commit f76ec1e

Browse files
committed
patch 8.2.2565: Vim9: "..=" not always recognized
Problem: Vim9: "..=" not always recognized. Solution: Do not consider "..=" to be string concatenation. (closes #7905)
1 parent 51b477f commit f76ec1e

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

src/eval.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,11 +2849,12 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
28492849
int vim9script = in_vim9script();
28502850

28512851
// "." is only string concatenation when scriptversion is 1
2852-
// "+=" and "-=" are assignment
2852+
// "+=", "-=" and "..=" are assignments
28532853
p = eval_next_non_blank(*arg, evalarg, &getnext);
28542854
op = *p;
28552855
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
2856-
if ((op != '+' && op != '-' && !concat) || p[1] == '=')
2856+
if ((op != '+' && op != '-' && !concat) || p[1] == '='
2857+
|| (p[1] == '.' && p[2] == '='))
28572858
break;
28582859

28592860
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
@@ -3080,9 +3081,10 @@ eval6(
30803081
#endif
30813082
int error;
30823083

3084+
// "*=", "/=" and "%=" are assignments
30833085
p = eval_next_non_blank(*arg, evalarg, &getnext);
30843086
op = *p;
3085-
if (op != '*' && op != '/' && op != '%')
3087+
if ((op != '*' && op != '/' && op != '%') || p[1] == '=')
30863088
break;
30873089

30883090
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);

src/testdir/test_vim9_assign.vim

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,44 @@ def Test_assign_dict_unknown_type()
10991099
CheckScriptSuccess(lines)
11001100
enddef
11011101

1102+
def Test_assign_dict_with_op()
1103+
var lines =<< trim END
1104+
vim9script
1105+
var ds: dict<string> = {a: 'x'}
1106+
ds['a'] ..= 'y'
1107+
ds.a ..= 'z'
1108+
assert_equal('xyz', ds.a)
1109+
1110+
var dn: dict<number> = {a: 9}
1111+
dn['a'] += 2
1112+
assert_equal(11, dn.a)
1113+
dn.a += 2
1114+
assert_equal(13, dn.a)
1115+
1116+
dn['a'] -= 3
1117+
assert_equal(10, dn.a)
1118+
dn.a -= 2
1119+
assert_equal(8, dn.a)
1120+
1121+
dn['a'] *= 2
1122+
assert_equal(16, dn.a)
1123+
dn.a *= 2
1124+
assert_equal(32, dn.a)
1125+
1126+
dn['a'] /= 3
1127+
assert_equal(10, dn.a)
1128+
dn.a /= 2
1129+
assert_equal(5, dn.a)
1130+
1131+
dn['a'] %= 3
1132+
assert_equal(2, dn.a)
1133+
dn.a %= 6
1134+
assert_equal(2, dn.a)
1135+
END
1136+
# TODO: this should also work with a :def function
1137+
CheckScriptSuccess(lines)
1138+
enddef
1139+
11021140
def Test_assign_lambda()
11031141
# check if assign a lambda to a variable which type is func or any.
11041142
var lines =<< trim END

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2565,
753755
/**/
754756
2564,
755757
/**/

0 commit comments

Comments
 (0)