patch 8.2.4573: a nested function is compiled for debugging without context
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)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 696301f..d8119c5 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -913,6 +913,7 @@
}
}
+ 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,6 +2580,13 @@
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);