diff src/vim9compile.c @ 25222:fbb530e081ca v8.2.3147

patch 8.2.3147: Vim9: profiling does not work with a nested function Commit: https://github.com/vim/vim/commit/648594eaf703fe9a862cb12a35702a10aff6e5a9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 11 17:55:01 2021 +0200 patch 8.2.3147: Vim9: profiling does not work with a nested function Problem: Vim9: profiling does not work with a nested function. Solution: Also compile a nested function without profiling. (closes https://github.com/vim/vim/issues/8543) Handle that compiling may cause the table of compiled functions to change.
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Jul 2021 18:00:04 +0200
parents 218df177cff8
children 10a5eb15a3bf
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3624,10 +3624,12 @@ compile_lambda(char_u **arg, cctx_T *cct
 	ufunc->uf_ret_type = &t_unknown;
     compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx);
 
+#ifdef FEAT_PROFILE
     // 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);
+#endif
 
     // 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.
@@ -5631,6 +5633,14 @@ compile_nested_function(exarg_T *eap, cc
 	goto theend;
     }
 
+#ifdef FEAT_PROFILE
+    // When the outer function is compiled for profiling, the nested function
+    // may be called without profiling.  Compile it here in the right context.
+    if (COMPILE_TYPE(ufunc) == CT_PROFILE
+				       && func_needs_compiling(ufunc, CT_NONE))
+	compile_def_function(ufunc, FALSE, CT_NONE, cctx);
+#endif
+
     if (is_global)
     {
 	char_u *func_name = vim_strnsave(name_start + 2,