Mercurial > vim
diff src/vim9execute.c @ 26323:3841da4eac23 v8.2.3692
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Commit: https://github.com/vim/vim/commit/38453528c3372293d70c8e85471a6188749ff331
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 28 22:00:12 2021 +0000
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Problem: Vim9: cannot use :func inside a :def function.
Solution: Make it work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Nov 2021 23:15:03 +0100 |
parents | 3d92646fe6c8 |
children | c189c40c9a22 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -3168,8 +3168,8 @@ exec_instructions(ectx_T *ectx) case ISN_FUNCREF: { partial_T *pt = ALLOC_CLEAR_ONE(partial_T); - dfunc_T *pt_dfunc = ((dfunc_T *)def_functions.ga_data) - + iptr->isn_arg.funcref.fr_func; + ufunc_T *ufunc; + funcref_T *funcref = &iptr->isn_arg.funcref; if (pt == NULL) goto theend; @@ -3178,8 +3178,18 @@ exec_instructions(ectx_T *ectx) vim_free(pt); goto theend; } - if (fill_partial_and_closure(pt, pt_dfunc->df_ufunc, - ectx) == FAIL) + if (funcref->fr_func_name == NULL) + { + dfunc_T *pt_dfunc = ((dfunc_T *)def_functions.ga_data) + + funcref->fr_dfunc_idx; + + ufunc = pt_dfunc->df_ufunc; + } + else + { + ufunc = find_func(funcref->fr_func_name, FALSE, NULL); + } + if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL) goto theend; tv = STACK_TV_BOT(0); ++ectx->ec_stack.ga_len; @@ -5454,10 +5464,17 @@ list_instructions(char *pfx, isn_T *inst case ISN_FUNCREF: { funcref_T *funcref = &iptr->isn_arg.funcref; - dfunc_T *df = ((dfunc_T *)def_functions.ga_data) - + funcref->fr_func; - - smsg("%s%4d FUNCREF %s", pfx, current, df->df_ufunc->uf_name); + char_u *name; + + if (funcref->fr_func_name == NULL) + { + dfunc_T *df = ((dfunc_T *)def_functions.ga_data) + + funcref->fr_dfunc_idx; + name = df->df_ufunc->uf_name; + } + else + name = funcref->fr_func_name; + smsg("%s%4d FUNCREF %s", pfx, current, name); } break;