Patch 8.2.2706

5 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 3, 2021, 3:47:53 PM4/3/21
to vim...@googlegroups.com

Patch 8.2.2706
Problem: Vim9: wrong line number reported for boolean operator.
Solution: Use the line number before skipping over line break.
(closes #8058)
Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.2705/src/vim9compile.c 2021-04-03 21:00:57.664184664 +0200
--- src/vim9compile.c 2021-04-03 21:34:42.222904826 +0200
***************
*** 4772,4777 ****
--- 4772,4781 ----
ga_init2(&end_ga, sizeof(int), 10);
while (p[0] == opchar && p[1] == opchar)
{
+ long start_lnum = SOURCING_LNUM;
+ int start_ctx_lnum = cctx->ctx_lnum;
+ int save_lnum;
+
if (next != NULL)
{
*arg = next_line_from_context(cctx, TRUE);
***************
*** 4790,4800 ****
--- 4794,4809 ----
generate_ppconst(cctx, ppconst);

// Every part must evaluate to a bool.
+ SOURCING_LNUM = start_lnum;
+ save_lnum = cctx->ctx_lnum;
+ cctx->ctx_lnum = start_ctx_lnum;
if (bool_on_stack(cctx) == FAIL)
{
+ cctx->ctx_lnum = save_lnum;
ga_clear(&end_ga);
return FAIL;
}
+ cctx->ctx_lnum = save_lnum;

if (ga_grow(&end_ga, 1) == FAIL)
{
*** ../vim-8.2.2705/src/testdir/test_vim9_expr.vim 2021-03-22 20:48:57.863992154 +0100
--- src/testdir/test_vim9_expr.vim 2021-04-03 21:38:31.922274939 +0200
***************
*** 467,482 ****
CheckScriptFailure(lines, 'E1004:', 2)
enddef

! func Test_expr3_fails()
! let msg = "White space required before and after '&&'"
! call CheckDefFailure(["var x = 1&&2"], msg, 1)
! call CheckDefFailure(["var x = 1 &&2"], msg, 1)
! call CheckDefFailure(["var x = 1&& 2"], msg, 1)

! call CheckDefFailure(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 1)

! call CheckDefExecFailure(['assert_equal(false, Record(1) && Record(4) && Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
! endfunc

" global variables to use for tests with the "any" type
let atrue = v:true
--- 467,496 ----
CheckScriptFailure(lines, 'E1004:', 2)
enddef

! def Test_expr3_fails()
! var msg = "White space required before and after '&&'"
! CheckDefFailure(["var x = 1&&2"], msg, 1)
! CheckDefFailure(["var x = 1 &&2"], msg, 1)
! CheckDefFailure(["var x = 1&& 2"], msg, 1)

! CheckDefFailure(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 1)

! CheckDefExecFailure(['assert_equal(false, Record(1) && Record(4) && Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
!
! var lines =<< trim END
! if 3
! && true
! endif
! END
! CheckDefExecFailure(lines, 'E1023:', 1)
!
! lines =<< trim END
! if 'yes'
! && true
! endif
! END
! CheckDefFailure(lines, 'E1012:', 1)
! enddef

" global variables to use for tests with the "any" type
let atrue = v:true
*** ../vim-8.2.2705/src/version.c 2021-04-03 21:00:57.668184656 +0200
--- src/version.c 2021-04-03 21:44:45.797272681 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2706,
/**/

--
"I can't complain, but sometimes I still do." (Joe Walsh)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages