diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-05 22:23:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-05 22:23:00 +0200 |
commit | 442b29c968eff1c8fec1a96418aa47be9cba62ea (patch) | |
tree | 0b2067136269b0d6d030fc7621048d90c11c244d /src/eval.c | |
parent | 5cb09620c1e0a0178c0dc986230997a8aac0e61a (diff) |
patch 8.2.3113: no error when for loop variable shadows script variablev8.2.3113
Problem: No error when for loop variable shadows script variable.
Solution: Check for the error. (closes #8512)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index 1a84d2c1f5..e0f0816030 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1777,7 +1777,10 @@ next_for_item(void *fi_void, char_u *arg) forinfo_T *fi = (forinfo_T *)fi_void; int result; int flag = ASSIGN_FOR_LOOP | (in_vim9script() - ? (ASSIGN_FINAL | ASSIGN_DECL | ASSIGN_NO_MEMBER_TYPE) + ? (ASSIGN_FINAL + // first round: error if variable exists + | (fi->fi_bi == 0 ? 0 : ASSIGN_DECL) + | ASSIGN_NO_MEMBER_TYPE) : 0); listitem_T *item; @@ -1807,6 +1810,7 @@ next_for_item(void *fi_void, char_u *arg) tv.v_lock = VAR_FIXED; tv.vval.v_string = vim_strnsave(fi->fi_string + fi->fi_byte_idx, len); fi->fi_byte_idx += len; + ++fi->fi_bi; result = ex_let_vars(arg, &tv, TRUE, fi->fi_semicolon, fi->fi_varcount, flag, NULL) == OK; vim_free(tv.vval.v_string); @@ -1819,6 +1823,7 @@ next_for_item(void *fi_void, char_u *arg) else { fi->fi_lw.lw_item = item->li_next; + ++fi->fi_bi; result = (ex_let_vars(arg, &item->li_tv, TRUE, fi->fi_semicolon, fi->fi_varcount, flag, NULL) == OK); } |