summaryrefslogtreecommitdiff
path: root/src/vim9execute.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-16 21:20:12 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-16 21:20:12 +0200
commit6f5b6dfb16228c0ce1e4379b7bafed02eaddbab2 (patch)
tree5ef46ff7e270b67cf076b0797e66bdb016e35ae7 /src/vim9execute.c
parentaa5fc4ec51b00e91f174ac83c8ff68becf5f42bb (diff)
downloadvim-git-6f5b6dfb16228c0ce1e4379b7bafed02eaddbab2.tar.gz
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled codev8.2.0771
Problem: Vim9: cannot call a compiled closure from not compiled code. Solution: Pass funcexe to call_user_func().
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index c910dbc96..fe6adda60 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -641,6 +641,7 @@ call_def_function(
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 @@ call_def_function(
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 @@ call_def_function(
{
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 @@ call_def_function(
{
// 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;
}