diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-05 11:36:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-05 11:36:52 +0200 |
commit | b4caa163ff7bfacd4bec00e4baa55b5669ff1191 (patch) | |
tree | 31da874d77068eaf8b63b97f3f956529259fd4c4 /src | |
parent | a6296200bd5191bab7efcdcc16c9e79eb498e8e0 (diff) | |
download | vim-git-b4caa163ff7bfacd4bec00e4baa55b5669ff1191.tar.gz |
patch 8.2.1367: Vim9: no error for missing white space around operatorv8.2.1367
Problem: Vim9: no error for missing white space around operator.
Solution: Check for white space around *, / and %.
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 22 | ||||
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 37 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 56 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c index 3c4e5bdef..b8367e0cf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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; diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 7e53a287d..ab274a10d 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -843,6 +843,15 @@ def Test_expr5_vim9script() lines =<< trim END vim9script + let var = 11 + + 77 - + 22 + assert_equal(66, var) + END + CheckScriptSuccess(lines) + + lines =<< trim END + vim9script let var = 'one' .. 'two' assert_equal('onetwo', var) @@ -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() diff --git a/src/version.c b/src/version.c index 97bdb24c0..7ec5d2d2e 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1367, +/**/ 1366, /**/ 1365, |