Patch 8.2.1433
Problem: Vim9: cannot mingle comments in multi-line lambda.
Solution: Skip over NULL lines. (closes #6694)
Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim
*** ../vim-8.2.1432/src/vim9compile.c 2020-08-12 18:34:25.060496986 +0200
--- src/vim9compile.c 2020-08-12 19:08:18.334385957 +0200
***************
*** 1729,1739 ****
char_u *line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[lnum];
char_u *p;
! if (line == NULL)
! break;
! p = skipwhite(line);
! if (*p != NUL && !vim9_comment_start(p))
! return p;
}
return NULL;
}
--- 1729,1741 ----
char_u *line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[lnum];
char_u *p;
! // ignore NULLs inserted for continuation lines
! if (line != NULL)
! {
! p = skipwhite(line);
! if (*p != NUL && !vim9_comment_start(p))
! return p;
! }
}
return NULL;
}
*** ../vim-8.2.1432/src/testdir/test_vim9_expr.vim 2020-08-12
18:50:31.887655765 +0200
--- src/testdir/test_vim9_expr.vim 2020-08-12 19:14:19.992550472 +0200
***************
*** 1433,1438 ****
--- 1433,1448 ----
CheckScriptFailure(lines, 'E1068:')
enddef
+ def LambdaWithComments(): func
+ return {x ->
+ # some comment
+ x == 1
+ # some comment
+ ||
+ x == 2
+ }
+ enddef
+
def Test_expr7_lambda()
let La = { -> 'result'}
assert_equal('result', La())
***************
*** 1466,1471 ****
--- 1476,1486 ----
assert_equal([{'key': 12}], filter(dl,
{_, v -> has_key(v, 'key') ? v['key'] == 12 : 0}))
+ assert_equal(false, LambdaWithComments()(0))
+ assert_equal(true, LambdaWithComments()(1))
+ assert_equal(true, LambdaWithComments()(2))
+ assert_equal(false, LambdaWithComments()(3))
+
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
enddef
*** ../vim-8.2.1432/src/version.c 2020-08-12 18:50:31.891655745 +0200
--- src/version.c 2020-08-12 19:09:19.190077775 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1433,
/**/
--
hundred-and-one symptoms of being an internet addict:
183. You move your coffeemaker next to your computer.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202008121716.07CHG6wq109127%40masaka.moolenaar.net.