diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-09 14:23:43 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-09 14:23:43 +0000 |
commit | dcb53be4418fe263a71c7738315241031df6c986 (patch) | |
tree | 06c0a6aeb6eae587344a5360b3b4cd0dd02c1a5d /src/vim9execute.c | |
parent | d0fb907253a5c5a71b1f231f3ddec24098fb4e21 (diff) | |
download | vim-git-dcb53be4418fe263a71c7738315241031df6c986.tar.gz |
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and othersv8.2.3765
Problem: Vim9: cannot use a lambda for 'opfunc' and others.
Solution: Convert the lambda to a string.
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r-- | src/vim9execute.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index f805dc0f1..874e57c58 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2336,10 +2336,14 @@ exec_instructions(ectx_T *ectx) // store option case ISN_STOREOPT: + case ISN_STOREFUNCOPT: { + char_u *opt_name = iptr->isn_arg.storeopt.so_name; + int opt_flags = iptr->isn_arg.storeopt.so_flags; long n = 0; char_u *s = NULL; char *msg; + callback_T cb = {NULL, NULL, 0}; --ectx->ec_stack.ga_len; tv = STACK_TV_BOT(0); @@ -2349,11 +2353,22 @@ exec_instructions(ectx_T *ectx) if (s == NULL) s = (char_u *)""; } + else if (iptr->isn_type == ISN_STOREFUNCOPT) + { + SOURCING_LNUM = iptr->isn_lnum; + cb = get_callback(tv); + if (cb.cb_name == NULL || *cb.cb_name == NUL) + { + clear_tv(tv); + free_callback(&cb); + goto on_error; + } + s = cb.cb_name; + } else // must be VAR_NUMBER, CHECKTYPE makes sure n = tv->vval.v_number; - msg = set_option_value(iptr->isn_arg.storeopt.so_name, - n, s, iptr->isn_arg.storeopt.so_flags); + msg = set_option_value(opt_name, n, s, opt_flags); clear_tv(tv); if (msg != NULL) { @@ -2361,6 +2376,8 @@ exec_instructions(ectx_T *ectx) emsg(_(msg)); goto on_error; } + if (cb.cb_name != NULL) + free_callback(&cb); } break; @@ -5335,7 +5352,9 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc) } break; case ISN_STOREOPT: - smsg("%s%4d STOREOPT &%s", pfx, current, + case ISN_STOREFUNCOPT: + smsg("%s%4d %s &%s", pfx, current, + iptr->isn_type == ISN_STOREOPT ? "STOREOPT" : "STOREFUNCOPT", iptr->isn_arg.storeopt.so_name); break; case ISN_STOREENV: |