comparison src/vim9compile.c @ 25230:658dfd6be868 v8.2.3151

patch 8.2.3151: Vim9: profiling fails if nested function is also profiled Commit: https://github.com/vim/vim/commit/ffcfddc759e583471a1ed55e0938d042bf68c507 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 11 20:22:30 2021 +0200 patch 8.2.3151: Vim9: profiling fails if nested function is also profiled Problem: Vim9: profiling fails if nested function is also profiled. Solution: Use the compile type from the outer function. (closes https://github.com/vim/vim/issues/8543)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Jul 2021 20:30:04 +0200
parents 10a5eb15a3bf
children 205a0126ac2d
comparison
equal deleted inserted replaced
25229:86d819a48d9f 25230:658dfd6be868
5568 char_u *name_start = eap->arg; 5568 char_u *name_start = eap->arg;
5569 char_u *name_end = to_name_end(eap->arg, TRUE); 5569 char_u *name_end = to_name_end(eap->arg, TRUE);
5570 char_u *lambda_name; 5570 char_u *lambda_name;
5571 ufunc_T *ufunc; 5571 ufunc_T *ufunc;
5572 int r = FAIL; 5572 int r = FAIL;
5573 compiletype_T compile_type;
5573 5574
5574 if (eap->forceit) 5575 if (eap->forceit)
5575 { 5576 {
5576 emsg(_(e_cannot_use_bang_with_nested_def)); 5577 emsg(_(e_cannot_use_bang_with_nested_def));
5577 return NULL; 5578 return NULL;
5634 sizeof(int) * block_depth); 5635 sizeof(int) * block_depth);
5635 ufunc->uf_block_depth = block_depth; 5636 ufunc->uf_block_depth = block_depth;
5636 } 5637 }
5637 } 5638 }
5638 5639
5639 if (func_needs_compiling(ufunc, COMPILE_TYPE(ufunc)) 5640 compile_type = COMPILE_TYPE(ufunc);
5640 && compile_def_function(ufunc, TRUE, COMPILE_TYPE(ufunc), cctx) 5641 #ifdef FEAT_PROFILE
5641 == FAIL) 5642 // If the outer function is profiled, also compile the nested function for
5643 // profiling.
5644 if (cctx->ctx_compile_type == CT_PROFILE)
5645 compile_type = CT_PROFILE;
5646 #endif
5647 if (func_needs_compiling(ufunc, compile_type)
5648 && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)
5642 { 5649 {
5643 func_ptr_unref(ufunc); 5650 func_ptr_unref(ufunc);
5644 goto theend; 5651 goto theend;
5645 } 5652 }
5646 5653
5647 #ifdef FEAT_PROFILE 5654 #ifdef FEAT_PROFILE
5648 // When the outer function is compiled for profiling, the nested function 5655 // When the outer function is compiled for profiling, the nested function
5649 // may be called without profiling. Compile it here in the right context. 5656 // may be called without profiling. Compile it here in the right context.
5650 if (COMPILE_TYPE(ufunc) == CT_PROFILE 5657 if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))
5651 && func_needs_compiling(ufunc, CT_NONE))
5652 compile_def_function(ufunc, FALSE, CT_NONE, cctx); 5658 compile_def_function(ufunc, FALSE, CT_NONE, cctx);
5653 #endif 5659 #endif
5654 5660
5655 if (is_global) 5661 if (is_global)
5656 { 5662 {