summaryrefslogtreecommitdiffstats
path: root/src/ex_eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-25 14:13:53 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-25 14:13:53 +0200
commit2eb6fc3b52148f961e804ec2be361d531ff770d8 (patch)
tree860366c5e83de91ee2531177158a60dcf7c13e3f /src/ex_eval.c
parent5bca906b307728fa74a112914dc55b424d512d39 (diff)
patch 8.2.3216: Vim9: crash when using variable in a loop at script levelv8.2.3216
Problem: Vim9: crash when using variable in a loop at script level. Solution: Do not clear the variable if a function was defined. Do not create a new entry in sn_var_vals every time. (closes #8628)
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r--src/ex_eval.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c
index 6491955d68..827f9cdcdb 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -972,9 +972,6 @@ leave_block(cstack_T *cstack)
hide_script_var(si, i, func_defined);
}
- // TODO: is this needed?
- cstack->cs_script_var_len[cstack->cs_idx] = si->sn_var_vals.ga_len;
-
if (cstack->cs_idx == 0)
si->sn_current_block_id = 0;
else
@@ -1178,6 +1175,8 @@ ex_while(exarg_T *eap)
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
int i;
+ int func_defined = cstack->cs_flags[cstack->cs_idx]
+ & CSF_FUNC_DEF;
// Any variables defined in the previous round are no longer
// visible.
@@ -1192,10 +1191,8 @@ ex_while(exarg_T *eap)
if (sv->sv_name != NULL)
// Remove a variable declared inside the block, if it
// still exists, from sn_vars.
- hide_script_var(si, i, FALSE);
+ hide_script_var(si, i, func_defined);
}
- cstack->cs_script_var_len[cstack->cs_idx] =
- si->sn_var_vals.ga_len;
}
}
cstack->cs_flags[cstack->cs_idx] =
@@ -1222,14 +1219,7 @@ ex_while(exarg_T *eap)
/*
* ":for var in list-expr"
*/
- CLEAR_FIELD(evalarg);
- evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE;
- if (getline_equal(eap->getline, eap->cookie, getsourceline))
- {
- evalarg.eval_getline = eap->getline;
- evalarg.eval_cookie = eap->cookie;
- }
-
+ fill_evalarg_from_eap(&evalarg, eap, skip);
if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0)
{
// Jumping here from a ":continue" or ":endfor": use the