]> granicus.if.org Git - vim/commitdiff
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong v8.2.3165
authorBram Moolenaar <Bram@vim.org>
Thu, 15 Jul 2021 13:40:58 +0000 (15:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 15 Jul 2021 13:40:58 +0000 (15:40 +0200)
Problem:    Vim9: in a || expression the error line number may be wrong.
Solution:   Save and restore the line number when checking the type.
            (closes #8569)

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

index 59ac9571310adaa900f1048c585312dbb1246c89..ae48a89604e99b9f8fab484532f7930ddbdc1c8d 100644 (file)
@@ -401,6 +401,13 @@ def Test_expr2_fails()
     # comment
   END
   CheckScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||true"', 3)
+
+  lines =<< trim END
+      var x = false
+              || false
+              || a.b
+  END
+  CheckDefFailure(lines, 'E1001:', 3)
 enddef
 
 " test &&
index 9d355c8ede1f2f105964f535c7a337ea0f7591d1..ba8362bccf4345f4da56aae4baf825148be77710 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3165,
 /**/
     3164,
 /**/
index d25183f19e4dbef7cc087a1d6bcc42eb6d68e6d3..4763e9550b2a64543d6f1d0e8f4e8c2fa71df352 100644 (file)
@@ -5095,6 +5095,7 @@ compile_and_or(
        while (p[0] == opchar && p[1] == opchar)
        {
            long        start_lnum = SOURCING_LNUM;
+           long        save_sourcing_lnum;
            int         start_ctx_lnum = cctx->ctx_lnum;
            int         save_lnum;
 
@@ -5116,6 +5117,7 @@ compile_and_or(
            generate_ppconst(cctx, ppconst);
 
            // Every part must evaluate to a bool.
+           save_sourcing_lnum = SOURCING_LNUM;
            SOURCING_LNUM = start_lnum;
            save_lnum = cctx->ctx_lnum;
            cctx->ctx_lnum = start_ctx_lnum;
@@ -5138,6 +5140,7 @@ compile_and_or(
                                 ?  JUMP_IF_COND_TRUE : JUMP_IF_COND_FALSE, 0);
 
            // eval the next expression
+           SOURCING_LNUM = save_sourcing_lnum;
            if (may_get_next_line_error(p + 2, arg, cctx) == FAIL)
            {
                ga_clear(&end_ga);