summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-09 22:50:08 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-09 22:50:08 +0200
commit09689a02840be40fa7bb10b1921fb5bc5b2908f1 (patch)
tree4aced60f6702ce56232c9ee70bf977234e054c39 /src/evalvars.c
parent396f3138ca83ce844679143861f544070683d479 (diff)
downloadvim-git-09689a02840be40fa7bb10b1921fb5bc5b2908f1.tar.gz
patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 scriptv8.2.0725
Problem: Vim9: cannot call a function declared later in Vim9 script. Solution: Make two passes through the script file.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 0935bb3eb..01aef1ae6 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -164,7 +164,6 @@ static dict_T vimvardict; // Dictionary with v: variables
// 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 @@ ex_let(exarg_T *eap)
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 @@ ex_let_const(exarg_T *eap, int is_const)
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 @@ set_var_const(
if (flags & LET_IS_CONST)
di->di_tv.v_lock |= VAR_LOCKED;
+ if (flags & LET_REDEFINE)
+ di->di_flags |= DI_FLAGS_RELOAD;
}
/*