]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1064: Vim9: no line break allowed before comperators v8.2.1064
authorBram Moolenaar <Bram@vim.org>
Fri, 26 Jun 2020 20:00:38 +0000 (22:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 26 Jun 2020 20:00:38 +0000 (22:00 +0200)
Problem:    Vim9: no line break allowed before comperators.
Solution:   Check for comperator after line break.

src/eval.c
src/testdir/test_vim9_expr.vim
src/version.c

index 9f06fd8d71b5eebe564a752e50e37c059954b453..1bfe808f54c34bef5202e242b1c1d4a0f68eea78 100644 (file)
@@ -2191,6 +2191,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
 {
     typval_T   var2;
     char_u     *p;
+    int                getnext;
     int                i;
     exptype_T  type = EXPR_UNKNOWN;
     int                len = 2;
@@ -2202,7 +2203,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
     if (eval5(arg, rettv, evalarg) == FAIL)
        return FAIL;
 
-    p = *arg;
+    p = eval_next_non_blank(*arg, evalarg, &getnext);
     switch (p[0])
     {
        case '=':   if (p[1] == '=')
@@ -2247,6 +2248,9 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
      */
     if (type != EXPR_UNKNOWN)
     {
+       if (getnext)
+           *arg = eval_next_line(evalarg);
+
        // extra question mark appended: ignore case
        if (p[len] == '?')
        {
index dcdaeb240357556c4638b15cdb4f3535be24f73e..de4d74165922f602fb0c9ac33363a2afec000126 100644 (file)
@@ -529,6 +529,43 @@ def RetVoid()
   let x = 1
 enddef
 
+def Test_expr4_vimscript()
+  " only checks line continuation
+  let lines =<< trim END
+      vim9script
+      let var = 0
+               < 1
+      assert_equal(1, var)
+  END
+  CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      let var = 123
+               != 123
+      assert_equal(0, var)
+  END
+  CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      let list = [1, 2, 3]
+      let var = list
+               is list
+      assert_equal(1, var)
+  END
+  CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      let myblob = 0z1234
+      let var = myblob
+               isnot 0z11
+      assert_equal(1, var)
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 func Test_expr4_fails()
   let msg = "white space required before and after '>'"
   call CheckDefFailure(["let x = 1>2"], msg)
index bdb43fcc574b5e979971ac7429dc9df0e174548b..eb0bf8dcdcfd32e8d32390afee7745ced3f89230 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1064,
 /**/
     1063,
 /**/