]> granicus.if.org Git - vim/commitdiff
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end v8.2.2349
authorBram Moolenaar <Bram@vim.org>
Thu, 14 Jan 2021 19:35:49 +0000 (20:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 14 Jan 2021 19:35:49 +0000 (20:35 +0100)
Problem:    Vim9: cannot handle line break after parenthesis at line end.
Solution:   Skip over line break. (closes #7677)

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

index 50537c858aa6f7a7f626f2aad2f5cafe31c53099..a45d0eae6e49ff1b3b3a89e61dcbe777f72a762f 100644 (file)
@@ -2523,18 +2523,26 @@ enddef
 
 def Test_expr7_parens()
   # (expr)
-  assert_equal(4, (6 * 4) / 6)
-  assert_equal(0, 6 * ( 4 / 6 ))
-
-  assert_equal(6, +6)
-  assert_equal(-6, -6)
-  assert_equal(false, !-3)
-  assert_equal(true, !+0)
-enddef
-
-def Test_expr7_parens_vim9script()
   var lines =<< trim END
-      vim9script
+      assert_equal(4, (6 * 4) / 6)
+      assert_equal(0, 6 * ( 4 / 6 ))
+
+      assert_equal(6, +6)
+      assert_equal(-6, -6)
+      assert_equal(false, !-3)
+      assert_equal(true, !+0)
+
+      assert_equal(7, 5 + (
+                    2))
+      assert_equal(7, 5 + (
+                    2
+                    ))
+      assert_equal(7, 5 + ( # comment
+                    2))
+      assert_equal(7, 5 + ( # comment
+                    # comment
+                    2))
+
       var s = (
                'one'
                ..
@@ -2542,7 +2550,7 @@ def Test_expr7_parens_vim9script()
                )
       assert_equal('onetwo', s)
   END
-  CheckScriptSuccess(lines)
+  CheckDefAndScriptSuccess(lines)
 enddef
 
 def Test_expr7_negate_add()
index cfc929073a1d8b4750fa46f5fbe5a63ce0831f50..48ba60f2f054c882651812769f2ce11a48e0eeb7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2349,
 /**/
     2348,
 /**/
index e25a36b75399c608f6bd5affd2e675785d2d9783..b0b5973dd594d4f9db94e7726f118c9a3c8d910f 100644 (file)
@@ -3554,8 +3554,10 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
 compile_parenthesis(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
 {
     int            ret;
+    char_u  *p = *arg + 1;
 
-    *arg = skipwhite(*arg + 1);
+    if (may_get_next_line_error(p, arg, cctx) == FAIL)
+       return FAIL;
     if (ppconst->pp_used <= PPSIZE - 10)
     {
        ret = compile_expr1(arg, cctx, ppconst);