changeset 21642:5ae89c8633ae v8.2.1371

patch 8.2.1371: Vim9: no error for missing white space around operator Commit: https://github.com/vim/vim/commit/3c1c9fd94bc80871119a8519f3b881595082a6c0 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 5 12:32:38 2020 +0200 patch 8.2.1371: 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 ||.
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Aug 2020 12:45:03 +0200
parents 20b0520f1174
children 08894a73765b
files src/eval.c src/testdir/test_vim9_expr.vim src/version.c
diffstat 3 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -2242,11 +2242,25 @@ eval2(char_u **arg, typval_T *rettv, eva
 	    if (getnext)
 		*arg = eval_next_line(evalarg_used);
 	    else
+	    {
+		if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+		{
+		    error_white_both(p, 2);
+		    clear_tv(rettv);
+		    return FAIL;
+		}
 		*arg = p;
+	    }
 
 	    /*
 	     * Get the second variable.
 	     */
+	    if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
+	    {
+		error_white_both(p, 2);
+		clear_tv(rettv);
+		return FAIL;
+	    }
 	    *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
 	    evalarg_used->eval_flags = !result ? orig_flags
 						 : orig_flags & ~EVAL_EVALUATE;
@@ -2359,11 +2373,25 @@ eval3(char_u **arg, typval_T *rettv, eva
 	    if (getnext)
 		*arg = eval_next_line(evalarg_used);
 	    else
+	    {
+		if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+		{
+		    error_white_both(p, 2);
+		    clear_tv(rettv);
+		    return FAIL;
+		}
 		*arg = p;
+	    }
 
 	    /*
 	     * Get the second variable.
 	     */
+	    if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
+	    {
+		error_white_both(p, 2);
+		clear_tv(rettv);
+		return FAIL;
+	    }
 	    *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
 	    evalarg_used->eval_flags = result ? orig_flags
 						 : orig_flags & ~EVAL_EVALUATE;
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -175,6 +175,23 @@ def Test_expr2_vimscript()
   END
   CheckScriptSuccess(lines)
 
+  # check white space
+  lines =<< trim END
+      vim9script
+      let var = v:true||v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+  lines =<< trim END
+      vim9script
+      let var = v:true ||v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+  lines =<< trim END
+      vim9script
+      let var = v:true|| v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+
   # check keeping the value
   lines =<< trim END
       vim9script
@@ -279,6 +296,23 @@ def Test_expr3_vimscript()
   END
   CheckScriptSuccess(lines)
 
+  # check white space
+  lines =<< trim END
+      vim9script
+      let var = v:true&&v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+  lines =<< trim END
+      vim9script
+      let var = v:true &&v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+  lines =<< trim END
+      vim9script
+      let var = v:true&& v:true
+  END
+  CheckScriptFailure(lines, 'E1004:')
+
   # check keeping the value
   lines =<< trim END
       vim9script
--- 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 */
 /**/
+    1371,
+/**/
     1370,
 /**/
     1369,