patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Problem: Vim9: cannot call a function declared later in Vim9 script.
Solution: Make two passes through the script file.
diff --git a/src/evalvars.c b/src/evalvars.c
index 0935bb3..01aef1a 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -164,7 +164,6 @@
// for VIM_VERSION_ defines
#include "version.h"
-static void ex_let_const(exarg_T *eap, int is_const);
static char_u *skip_var_one(char_u *arg, int include_type);
static void list_glob_vars(int *first);
static void list_buf_vars(int *first);
@@ -698,11 +697,15 @@
void
ex_const(exarg_T *eap)
{
- ex_let_const(eap, TRUE);
+ ex_let_const(eap, FALSE);
}
- static void
-ex_let_const(exarg_T *eap, int is_const)
+/*
+ * When "redefine" is TRUE the command will be executed again, redefining the
+ * variable is OK then.
+ */
+ void
+ex_let_const(exarg_T *eap, int redefine)
{
char_u *arg = eap->arg;
char_u *expr = NULL;
@@ -714,11 +717,13 @@
char_u *argend;
int first = TRUE;
int concat;
- int flags = is_const ? LET_IS_CONST : 0;
+ int flags = eap->cmdidx == CMD_const ? LET_IS_CONST : 0;
// detect Vim9 assignment without ":let" or ":const"
if (eap->arg == eap->cmd)
flags |= LET_NO_COMMAND;
+ if (redefine)
+ flags |= LET_REDEFINE;
argend = skip_var_list(arg, TRUE, &var_count, &semicolon);
if (argend == NULL)
@@ -2976,6 +2981,8 @@
if (flags & LET_IS_CONST)
di->di_tv.v_lock |= VAR_LOCKED;
+ if (flags & LET_REDEFINE)
+ di->di_flags |= DI_FLAGS_RELOAD;
}
/*