++fi->fi_tuple_idx;
++fi->fi_bi;
if (skip_assign)
- return TRUE;
- return ex_let_vars(arg, &tv, TRUE, fi->fi_semicolon,
+ result = TRUE;
+ else
+ result = ex_let_vars(arg, &tv, TRUE, fi->fi_semicolon,
fi->fi_varcount, flag, NULL) == OK;
+ clear_tv(&tv);
+ return result;
}
item = fi->fi_lw.lw_item;
LET sum += v2
endfor
call assert_equal(0, sum)
+
+ #" iterating over string items; the copied item must not be leaked
+ VAR res = ''
+ for v3 in ('a', 'bb', 'ccc')
+ LET res ..= v3
+ endfor
+ call assert_equal('abbccc', res)
+
+ #" iterating over container items must not leak a reference
+ VAR flat = []
+ for v4 in (['a'], ['b', 'c'])
+ LET flat += v4
+ endfor
+ call assert_equal(['a', 'b', 'c'], flat)
END
call v9.CheckSourceLegacyAndVim9Success(lines)
END
call v9.CheckSourceSuccess(lines)
+ " ignoring the for loop assignment using '_'; string items must not be
+ " leaked
+ let lines =<< trim END
+ vim9script
+ var count = 0
+ for _ in ('a', 'bb', 'ccc')
+ count += 1
+ endfor
+ assert_equal(3, count)
+ END
+ call v9.CheckSourceSuccess(lines)
+
let lines =<< trim END
var sum = 0
for v in null_tuple