Patch 8.2.3143
Problem: Vim9: A lambda may be compiled with the wrong context if it is
called from a profiled function.
Solution: Compile the lambda with and without profiling. (closes #8543)
Files: src/vim9compile.c, src/testdir/test_vim9_script.vim
*** ../vim-8.2.3142/src/vim9compile.c 2021-07-10 19:41:59.916341599 +0200
--- src/vim9compile.c 2021-07-11 15:25:11.103105165 +0200
***************
*** 3624,3629 ****
--- 3624,3634 ----
ufunc->uf_ret_type = &t_unknown;
compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx);
+ // When the outer function is compiled for profiling, the lambda may be
+ // called without profiling. Compile it here in the right context.
+ if (cctx->ctx_compile_type == CT_PROFILE)
+ compile_def_function(ufunc, FALSE, CT_NONE, cctx);
+
// evalarg.eval_tofree_cmdline may have a copy of the last line and "*arg"
// points into it. Point to the original line to avoid a dangling
pointer.
if (evalarg.eval_tofree_cmdline != NULL)
*** ../vim-8.2.3142/src/testdir/test_vim9_script.vim 2021-07-10
19:41:59.916341599 +0200
--- src/testdir/test_vim9_script.vim 2021-07-11 15:24:33.299146464 +0200
***************
*** 4167,4172 ****
--- 4167,4185 ----
set hlsearch&
enddef
+ def ProfiledFunc()
+ var n = 3
+ echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n)
+ enddef
+
+ " Execute this near the end, profiling doesn't stop until Vim exists.
+ " This only tests that it works, not the profiling output.
+ def Test_xx_profile_with_lambda()
+ profile start Xprofile.log
+ profile func ProfiledFunc
+ ProfiledFunc()
+ enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
*** ../vim-8.2.3142/src/version.c 2021-07-11 14:55:45.253356763 +0200
--- src/version.c 2021-07-11 15:20:55.599356889 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3143,
/**/
--
Two percent of zero is almost nothing.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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/202107111326.16BDQiJO823442%40masaka.moolenaar.net.