patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Problem: Vim9: cannot call a function declared later in Vim9 script.
Solution: Make two passes through the script file.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index a505647..bfa2492 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -669,6 +669,13 @@
ga_init2(&ectx.ec_stack, sizeof(typval_T), 500);
if (ga_grow(&ectx.ec_stack, 20) == FAIL)
return FAIL;
+ {
+ // Check the function was compiled, it is postponed in ex_vim9script().
+ dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ + ufunc->uf_dfunc_idx;
+ if (dfunc->df_instr == NULL)
+ return FAIL;
+ }
ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10);