Mercurial > vim
diff src/vim9execute.c @ 21558:1c4d4aa22b37 v8.2.1329
patch 8.2.1329: Vim9: cannot define global function inside :def function
Commit: https://github.com/vim/vim/commit/38ddf333f6b2806b0ea2dd052ee1cd50dd7f4525
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 31 22:05:04 2020 +0200
patch 8.2.1329: Vim9: cannot define global function inside :def function
Problem: Vim9: cannot define global function inside :def function.
Solution: Assign to global variable instead of local. (closes https://github.com/vim/vim/issues/6584)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 31 Jul 2020 22:15:04 +0200 |
parents | 279b3415947f |
children | b8b15e8cbf5f |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -723,7 +723,10 @@ call_def_function( dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx; if (dfunc->df_instr == NULL) + { + iemsg("using call_def_function() on not compiled function"); return FAIL; + } } CLEAR_FIELD(ectx); @@ -1726,6 +1729,15 @@ call_def_function( } break; + // Create a global function from a lambda. + case ISN_NEWFUNC: + { + newfunc_T *newfunc = &iptr->isn_arg.newfunc; + + copy_func(newfunc->nf_lambda, newfunc->nf_global); + } + break; + // jump if a condition is met case ISN_JUMP: { @@ -2912,6 +2924,15 @@ ex_disassemble(exarg_T *eap) } break; + case ISN_NEWFUNC: + { + newfunc_T *newfunc = &iptr->isn_arg.newfunc; + + smsg("%4d NEWFUNC %s %s", current, + newfunc->nf_lambda, newfunc->nf_global); + } + break; + case ISN_JUMP: { char *when = "?";