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.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 4271f38..fda44ec 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -487,10 +487,10 @@
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 @@
// 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 @@
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;