patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Problem: Vim9: cannot call a compiled closure from not compiled code.
Solution: Pass funcexe to call_user_func().
diff --git a/src/vim9execute.c b/src/vim9execute.c
index c910dbc..fe6adda 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -641,6 +641,7 @@
ufunc_T *ufunc,
int argc_arg, // nr of arguments
typval_T *argv, // arguments
+ partial_T *partial, // optional partial for context
typval_T *rettv) // return value
{
ectx_T ectx; // execution context
@@ -720,6 +721,12 @@
ectx.ec_frame_idx = ectx.ec_stack.ga_len;
initial_frame_idx = ectx.ec_frame_idx;
+ if (partial != NULL)
+ {
+ ectx.ec_outer_stack = partial->pt_ectx_stack;
+ ectx.ec_outer_frame = partial->pt_ectx_frame;
+ }
+
// dummy frame entries
for (idx = 0; idx < STACK_FRAME_SIZE; ++idx)
{
@@ -1468,7 +1475,7 @@
{
cpfunc_T *pfunc = &iptr->isn_arg.pfunc;
int r;
- typval_T partial;
+ typval_T partial_tv;
SOURCING_LNUM = iptr->isn_lnum;
if (pfunc->cpf_top)
@@ -1480,12 +1487,12 @@
{
// Get the funcref from the stack.
--ectx.ec_stack.ga_len;
- partial = *STACK_TV_BOT(0);
- tv = &partial;
+ partial_tv = *STACK_TV_BOT(0);
+ tv = &partial_tv;
}
r = call_partial(tv, pfunc->cpf_argcount, &ectx);
- if (tv == &partial)
- clear_tv(&partial);
+ if (tv == &partial_tv)
+ clear_tv(&partial_tv);
if (r == FAIL)
goto failed;
}