Mercurial > vim
diff src/vim9execute.c @ 20943:1693ca876049 v8.2.1023
patch 8.2.1023: Vim9: redefining a function uses a new index every time
Commit: https://github.com/vim/vim/commit/0cb5bcf5836de83f7d64fb01d3ce708caacaf66c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 20 18:19:09 2020 +0200
patch 8.2.1023: Vim9: redefining a function uses a new index every time
Problem: Vim9: redefining a function uses a new index every time.
Solution: When redefining a function clear the contents and re-use the
index.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Jun 2020 18:30:04 +0200 |
parents | 96bf2b304932 |
children | 4d844a65183d |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -487,10 +487,10 @@ call_ufunc(ufunc_T *ufunc, int argcount, int error; int idx; - if (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED + if (ufunc->uf_def_status == UF_TO_BE_COMPILED && compile_def_function(ufunc, FALSE, NULL) == FAIL) return FAIL; - if (ufunc->uf_dfunc_idx >= 0) + if (ufunc->uf_def_status == UF_COMPILED) { // The function has been compiled, can call it quickly. For a function // that was defined later: we can call it directly next time. @@ -671,8 +671,8 @@ 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 + if (ufunc->uf_def_status == UF_NOT_COMPILED + || (ufunc->uf_def_status == UF_TO_BE_COMPILED && compile_def_function(ufunc, FALSE, NULL) == FAIL)) { if (called_emsg == called_emsg_before) @@ -2379,10 +2379,10 @@ ex_disassemble(exarg_T *eap) semsg(_("E1061: Cannot find function %s"), eap->arg); return; } - if (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED + if (ufunc->uf_def_status == UF_TO_BE_COMPILED && compile_def_function(ufunc, FALSE, NULL) == FAIL) return; - if (ufunc->uf_dfunc_idx < 0) + if (ufunc->uf_def_status != UF_COMPILED) { semsg(_("E1062: Function %s is not compiled"), eap->arg); return;