summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-05 11:51:30 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-05 11:51:30 +0200
commitff1cd39cfe62d5089d5e703f4eb290694751ace3 (patch)
tree57070a46bb4b9e498a5113a226560668a0b84919
parentb4caa163ff7bfacd4bec00e4baa55b5669ff1191 (diff)
patch 8.2.1368: Vim9: no error for missing white space around operatorv8.2.1368
Problem: Vim9: no error for missing white space around operator. Solution: Check for white space around <, !=, etc.
-rw-r--r--src/eval.c24
-rw-r--r--src/testdir/test_vim9_expr.vim32
-rw-r--r--src/version.c2
3 files changed, 53 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c
index b8367e0cfb..6411ffa146 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2422,7 +2422,7 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* var1 isnot var2
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2452,9 +2452,17 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
typval_T var2;
int ic;
int vim9script = in_vim9script();
+ int evaluate = evalarg == NULL
+ ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
+ else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
+ {
+ error_white_both(p, len);
+ clear_tv(rettv);
+ return FAIL;
+ }
if (vim9script && type_is && (p[len] == '?' || p[len] == '#'))
{
@@ -2482,13 +2490,19 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
+ if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = skipwhite_and_linebreak(p + len, evalarg);
if (eval5(arg, &var2, evalarg) == FAIL)
{
clear_tv(rettv);
return FAIL;
}
- if (evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE))
+ if (evaluate)
{
int ret;
@@ -2552,7 +2566,7 @@ eval_addlist(typval_T *tv1, typval_T *tv2)
* .. string concatenation
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2754,7 +2768,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* % number modulo
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2956,7 +2970,7 @@ eval6(
* trailing ->name() method call
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index ab274a10df..aa7aed72a1 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -726,6 +726,38 @@ def Test_expr4_vimscript()
set noignorecase
END
CheckScriptSuccess(lines)
+
+ # check missing white space
+ lines =<< trim END
+ vim9script
+ echo 2>3
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ echo 2 >3
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ echo 2> 3
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ echo 2!=3
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ echo 2 !=3
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ echo 2!= 3
+ END
+ CheckScriptFailure(lines, 'E1004:')
enddef
func Test_expr4_fails()
diff --git a/src/version.c b/src/version.c
index 7ec5d2d2e4..2609eb7e08 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 */
/**/
+ 1368,
+/**/
1367,
/**/
1366,