commit 681ec17b507a1964d598dd3f5ef5340c6dad5408
parent 58ee249c2cd9c6183af86e26801d2ef9f9ad89b0
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date: Tue, 9 Sep 2025 00:20:18 -0400
vim-patch:8.1.1940: script tests fail
Problem: Script tests fail.
Solution: Don't set vimvars type in set_vim_var_nr().
https://github.com/vim/vim/commit/34ed68d40eb9c71f34a44b94263f5e7e6856cba0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
@@ -5481,7 +5481,8 @@ static void filter_map_blob(blob_T *blob_arg, filtermap_T filtermap, typval_T *e
b_ret = rettv->vval.v_blob;
}
- vimvars[VV_KEY].vv_type = VAR_NUMBER;
+ // set_vim_var_nr() doesn't set the type
+ set_vim_var_type(VV_KEY, VAR_NUMBER);
const VarLockStatus prev_lock = b->bv_lock;
if (b->bv_lock == 0) {
@@ -5532,7 +5533,8 @@ static void filter_map_string(const char *str, filtermap_T filtermap, typval_T *
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
- vimvars[VV_KEY].vv_type = VAR_NUMBER;
+ // set_vim_var_nr() doesn't set the type
+ set_vim_var_type(VV_KEY, VAR_NUMBER);
garray_T ga;
ga_init(&ga, (int)sizeof(char), 80);
@@ -5598,8 +5600,8 @@ static void filter_map_list(list_T *l, filtermap_T filtermap, const char *func_n
tv_list_alloc_ret(rettv, kListLenUnknown);
l_ret = rettv->vval.v_list;
}
-
- vimvars[VV_KEY].vv_type = VAR_NUMBER;
+ // set_vim_var_nr() doesn't set the type
+ set_vim_var_type(VV_KEY, VAR_NUMBER);
const VarLockStatus prev_lock = tv_list_locked(l);
if (tv_list_locked(l) == VAR_UNLOCKED) {
@@ -6965,14 +6967,23 @@ void set_vcount(int64_t count, int64_t count1, bool set_prevcount)
vimvars[VV_COUNT1].vv_nr = count1;
}
+/// Set type of v: variable to the given type.
+///
+/// @param[in] idx Index of variable to set.
+/// @param[in] type Type to set to.
+void set_vim_var_type(const VimVarIndex idx, const VarType type)
+{
+ vimvars[idx].vv_type = type;
+}
+
/// Set number v: variable to the given value
+/// Note that this does not set the type, use set_vim_var_type() for that.
///
/// @param[in] idx Index of variable to set.
/// @param[in] val Value to set to.
void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val)
{
tv_clear(&vimvars[idx].vv_tv);
- vimvars[idx].vv_type = VAR_NUMBER;
vimvars[idx].vv_nr = val;
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
@@ -3344,6 +3344,9 @@ static varnumber_T indexof_blob(blob_T *b, varnumber_T startidx, typval_T *expr)
}
}
+ set_vim_var_type(VV_KEY, VAR_NUMBER);
+ set_vim_var_type(VV_VAL, VAR_NUMBER);
+
const int called_emsg_start = called_emsg;
for (varnumber_T idx = startidx; idx < tv_blob_len(b); idx++) {
set_vim_var_nr(VV_KEY, idx);
@@ -3385,6 +3388,8 @@ static varnumber_T indexof_list(list_T *l, varnumber_T startidx, typval_T *expr)
}
}
+ set_vim_var_type(VV_KEY, VAR_NUMBER);
+
const int called_emsg_start = called_emsg;
for (; item != NULL; item = TV_LIST_ITEM_NEXT(l, item), idx++) {
set_vim_var_nr(VV_KEY, idx);
diff --git a/src/nvim/main.c b/src/nvim/main.c
@@ -709,6 +709,7 @@ void getout(int exitval)
exitval += ex_exitval;
}
+ set_vim_var_type(VV_EXITING, VAR_NUMBER);
set_vim_var_nr(VV_EXITING, exitval);
// Invoked all deferred functions in the function stack.