1
0
forked from aniani/vim

patch 8.2.1367: Vim9: no error for missing white space around operator

Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around *, / and %.
This commit is contained in:
Bram Moolenaar 2020-08-05 11:36:52 +02:00
parent a6296200bd
commit b4caa163ff
3 changed files with 56 additions and 5 deletions

View File

@ -2586,13 +2586,14 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
oplen = (concat && p[1] == '.') ? 2 : 1;
if (getnext)
*arg = eval_next_line(evalarg);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, 1);
error_white_both(p, oplen);
clear_tv(rettv);
return FAIL;
}
@ -2622,7 +2623,6 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
oplen = (op == '.' && *(*arg + 1) == '.') ? 2 : 1;
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
{
error_white_both(p, oplen);
@ -2796,17 +2796,25 @@ eval6(
if (op != '*' && op != '/' && op != '%')
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = p;
}
#ifdef FEAT_FLOAT
f1 = 0;
f2 = 0;
#endif
error = FALSE;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (evaluate)
{
#ifdef FEAT_FLOAT
@ -2829,7 +2837,13 @@ eval6(
/*
* Get the second variable.
*/
*arg = skipwhite(*arg + 1);
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (eval7(arg, &var2, evalarg, FALSE) == FAIL)
return FAIL;

View File

@ -841,6 +841,15 @@ def Test_expr5_vim9script()
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 +
77 -
22
assert_equal(66, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 'one'
@ -999,7 +1008,7 @@ def Test_expr6()
enddef
def Test_expr6_vim9script()
# only checks line continuation
# check line continuation
let lines =<< trim END
vim9script
let var = 11
@ -1016,6 +1025,32 @@ def Test_expr6_vim9script()
assert_equal(5, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 *
22 /
3
assert_equal(80, var)
END
CheckScriptSuccess(lines)
# check white space
lines =<< trim END
vim9script
echo 5*6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5 *6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5* 6
END
CheckScriptFailure(lines, 'E1004:')
enddef
def Test_expr6_float()

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1367,
/**/
1366,
/**/