summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-15 15:40:58 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-15 15:40:58 +0200
commit9e60e899ee546a8a35c4cbe0319971719c1839e9 (patch)
tree4126ed67ce70ed34c5f857acea53ab21ce4374e7
parent0894e0d8087aad4d467fd7b3d87b1930fe661916 (diff)
patch 8.2.3165: Vim9: in a || expression the error line number may be wrongv8.2.3165
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)
-rw-r--r--src/testdir/test_vim9_expr.vim7
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
3 files changed, 12 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 59ac957131..ae48a89604 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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 &&
diff --git a/src/version.c b/src/version.c
index 9d355c8ede..ba8362bccf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3165,
+/**/
3164,
/**/
3163,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index d25183f19e..4763e9550b 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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);