mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2565: Vim9: "..=" not always recognized
Problem: Vim9: "..=" not always recognized. Solution: Do not consider "..=" to be string concatenation. (closes #7905)
This commit is contained in:
@@ -2849,11 +2849,12 @@ 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
|
// "+=", "-=" and "..=" are assignments
|
||||||
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) || p[1] == '=')
|
if ((op != '+' && op != '-' && !concat) || p[1] == '='
|
||||||
|
|| (p[1] == '.' && p[2] == '='))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
@@ -3080,9 +3081,10 @@ eval6(
|
|||||||
#endif
|
#endif
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
// "*=", "/=" and "%=" are assignments
|
||||||
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
op = *p;
|
op = *p;
|
||||||
if (op != '*' && op != '/' && op != '%')
|
if ((op != '*' && op != '/' && op != '%') || p[1] == '=')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
|
@@ -1099,6 +1099,44 @@ def Test_assign_dict_unknown_type()
|
|||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_assign_dict_with_op()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var ds: dict<string> = {a: 'x'}
|
||||||
|
ds['a'] ..= 'y'
|
||||||
|
ds.a ..= 'z'
|
||||||
|
assert_equal('xyz', ds.a)
|
||||||
|
|
||||||
|
var dn: dict<number> = {a: 9}
|
||||||
|
dn['a'] += 2
|
||||||
|
assert_equal(11, dn.a)
|
||||||
|
dn.a += 2
|
||||||
|
assert_equal(13, dn.a)
|
||||||
|
|
||||||
|
dn['a'] -= 3
|
||||||
|
assert_equal(10, dn.a)
|
||||||
|
dn.a -= 2
|
||||||
|
assert_equal(8, dn.a)
|
||||||
|
|
||||||
|
dn['a'] *= 2
|
||||||
|
assert_equal(16, dn.a)
|
||||||
|
dn.a *= 2
|
||||||
|
assert_equal(32, dn.a)
|
||||||
|
|
||||||
|
dn['a'] /= 3
|
||||||
|
assert_equal(10, dn.a)
|
||||||
|
dn.a /= 2
|
||||||
|
assert_equal(5, dn.a)
|
||||||
|
|
||||||
|
dn['a'] %= 3
|
||||||
|
assert_equal(2, dn.a)
|
||||||
|
dn.a %= 6
|
||||||
|
assert_equal(2, dn.a)
|
||||||
|
END
|
||||||
|
# TODO: this should also work with a :def function
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_assign_lambda()
|
def Test_assign_lambda()
|
||||||
# check if assign a lambda to a variable which type is func or any.
|
# check if assign a lambda to a variable which type is func or any.
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
2565,
|
||||||
/**/
|
/**/
|
||||||
2564,
|
2564,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user