patch 8.2.0823: Vim9: script reload test is disabled
Problem: Vim9: script reload test is disabled.
Solution: Compile a function in the context of the script where it was
defined. Set execution stack for compiled function. Add a test
that an error is reported for the right file/function.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index f6aa140..1a87476 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -230,7 +230,7 @@
// Set execution state to the start of the called function.
ectx->ec_dfunc_idx = cdf_idx;
ectx->ec_instr = dfunc->df_instr;
- estack_push_ufunc(ETYPE_UFUNC, dfunc->df_ufunc, 1);
+ estack_push_ufunc(dfunc->df_ufunc, 1);
// Decide where to start execution, handles optional arguments.
init_instr_idx(ufunc, argcount, ectx);
@@ -656,6 +656,7 @@
int defcount = ufunc->uf_args.ga_len - argc;
int save_sc_version = current_sctx.sc_version;
int breakcheck_count = 0;
+ int called_emsg_before = called_emsg;
// Get pointer to item in the stack.
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -673,7 +674,13 @@
if (ufunc->uf_dfunc_idx == UF_NOT_COMPILED
|| (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED
&& compile_def_function(ufunc, FALSE, NULL) == FAIL))
+ {
+ if (called_emsg == called_emsg_before)
+ semsg(_("E1091: Function is not compiled: %s"),
+ ufunc->uf_name_exp == NULL
+ ? ufunc->uf_name : ufunc->uf_name_exp);
return FAIL;
+ }
{
// Check the function was really compiled.