Mercurial > vim
diff src/vim9execute.c @ 20528:489cb75c76b6 v8.2.0818
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Commit: https://github.com/vim/vim/commit/822ba24743af9ee1b5e7f656a7a61a38f3638bca
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 24 23:00:18 2020 +0200
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Problem: Vim9: using a discovery phase doesn't work well.
Solution: Remove the discovery phase, instead compile a function only when
it is used. Add :defcompile to compile def functions earlier.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 24 May 2020 23:15:04 +0200 |
parents | 5950284a517f |
children | 9f921ba86d05 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -487,6 +487,9 @@ call_ufunc(ufunc_T *ufunc, int argcount, int error; int idx; + if (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED + && compile_def_function(ufunc, FALSE, NULL) == FAIL) + return FAIL; if (ufunc->uf_dfunc_idx >= 0) { // The function has been compiled, can call it quickly. For a function @@ -667,8 +670,13 @@ call_def_function( // Like STACK_TV_VAR but use the outer scope #define STACK_OUT_TV_VAR(idx) (((typval_T *)ectx.ec_outer_stack->ga_data) + ectx.ec_outer_frame + STACK_FRAME_SIZE + idx) + if (ufunc->uf_dfunc_idx == UF_NOT_COMPILED + || (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED + && compile_def_function(ufunc, FALSE, NULL) == FAIL)) + return FAIL; + { - // Check the function was compiled, it is postponed in ex_vim9script(). + // Check the function was really compiled. dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx; if (dfunc->df_instr == NULL) @@ -2303,6 +2311,9 @@ ex_disassemble(exarg_T *eap) semsg(_("E1061: Cannot find function %s"), eap->arg); return; } + if (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED + && compile_def_function(ufunc, FALSE, NULL) == FAIL) + return; if (ufunc->uf_dfunc_idx < 0) { semsg(_("E1062: Function %s is not compiled"), eap->arg);