To: vim_dev@googlegroups.com Subject: Patch 8.2.1433 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- 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 ///