To: vim_dev@googlegroups.com Subject: Patch 8.2.4573 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4573 Problem: A nested function (closure) is compiled for debugging without context. Solution: Check if a nested function is marked for debugging before compiling it. Give an error when trying to compile a closure without its context. (closes #9951) Files: src/vim9compile.c, src/vim9execute.c, src/proto/vim9execute.pro, src/vim9expr.c, src/errors.h *** ../vim-8.2.4572/src/vim9compile.c 2022-03-13 13:12:23.767131845 +0000 --- src/vim9compile.c 2022-03-15 15:36:29.559231314 +0000 *************** *** 913,918 **** --- 913,919 ---- } } + update_has_breakpoint(ufunc); compile_type = COMPILE_TYPE(ufunc); #ifdef FEAT_PROFILE // If the outer function is profiled, also compile the nested function for *************** *** 2579,2584 **** --- 2580,2592 ---- new_def_function = TRUE; } + if ((ufunc->uf_flags & FC_CLOSURE) && outer_cctx == NULL) + { + semsg(_(e_compiling_closure_without_context_str), + printable_func_name(ufunc)); + return FAIL; + } + ufunc->uf_def_status = UF_COMPILING; CLEAR_FIELD(cctx); *** ../vim-8.2.4572/src/vim9execute.c 2022-03-10 20:47:38.553606225 +0000 --- src/vim9execute.c 2022-03-15 15:03:14.528263758 +0000 *************** *** 152,158 **** * If debug_tick changed check if "ufunc" has a breakpoint and update * "uf_has_breakpoint". */ ! static void update_has_breakpoint(ufunc_T *ufunc) { if (ufunc->uf_debug_tick != debug_tick) --- 152,158 ---- * If debug_tick changed check if "ufunc" has a breakpoint and update * "uf_has_breakpoint". */ ! void update_has_breakpoint(ufunc_T *ufunc) { if (ufunc->uf_debug_tick != debug_tick) *** ../vim-8.2.4572/src/proto/vim9execute.pro 2021-12-14 18:14:34.125509146 +0000 --- src/proto/vim9execute.pro 2022-03-15 15:03:47.076206565 +0000 *************** *** 1,5 **** --- 1,6 ---- /* vim9execute.c */ void to_string_error(vartype_T vartype); + void update_has_breakpoint(ufunc_T *ufunc); void funcstack_check_refcount(funcstack_T *funcstack); int set_ref_in_funcstacks(int copyID); char_u *char_from_string(char_u *str, varnumber_T index); *** ../vim-8.2.4572/src/vim9expr.c 2022-03-08 13:18:10.809020782 +0000 --- src/vim9expr.c 2022-03-15 15:24:30.895849990 +0000 *************** *** 1007,1012 **** --- 1007,1020 ---- ) compile_def_function(ufunc, FALSE, CT_NONE, cctx); + // if the outer function is not compiled for debugging, this one might be + if (cctx->ctx_compile_type != CT_DEBUG) + { + update_has_breakpoint(ufunc); + if (COMPILE_TYPE(ufunc) == CT_DEBUG) + compile_def_function(ufunc, FALSE, CT_DEBUG, cctx); + } + // The last entry in evalarg.eval_tofree_ga is a copy of the last line and // "*arg" may point into it. Point into the original line to avoid a // dangling pointer. *** ../vim-8.2.4572/src/errors.h 2022-03-05 22:07:29.133523260 +0000 --- src/errors.h 2022-03-15 15:33:20.927428392 +0000 *************** *** 3249,3251 **** --- 3249,3255 ---- #endif EXTERN char e_cannot_use_s_backslash_in_vim9_script[] INIT(= N_("E1270: Cannot use :s\\/sub/ in Vim9 script")); + #ifdef FEAT_EVAL + EXTERN char e_compiling_closure_without_context_str[] + INIT(= N_("E1271: compiling closure without context: %s")); + #endif *** ../vim-8.2.4572/src/version.c 2022-03-15 12:28:06.041374341 +0000 --- src/version.c 2022-03-15 15:03:40.172218737 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4573, /**/ -- hundred-and-one symptoms of being an internet addict: 269. You wonder how you can make your dustbin produce Sesame Street's Oscar's the Garbage Monster song when you empty it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///