patch 8.2.4285: Vim9: type of item in for loop not checked properly
Problem: Vim9: type of item in for loop not checked properly.
Solution: Adjust the type checking. (closes #9683)
diff --git a/src/vim9cmds.c b/src/vim9cmds.c
index 716a404..90b61db 100644
--- a/src/vim9cmds.c
+++ b/src/vim9cmds.c
@@ -990,11 +990,8 @@
if (lhs_type == &t_any)
lhs_type = item_type;
else if (item_type != &t_unknown
- && (item_type == &t_any
- ? need_type(item_type, lhs_type,
- -1, 0, cctx, FALSE, FALSE)
- : check_type(lhs_type, item_type, TRUE, where))
- == FAIL)
+ && need_type_where(item_type, lhs_type, -1,
+ where, cctx, FALSE, FALSE) == FAIL)
goto failed;
var_lvar = reserve_local(cctx, arg, varlen, TRUE, lhs_type);
if (var_lvar == NULL)
@@ -1003,8 +1000,6 @@
if (semicolon && idx == var_count - 1)
var_lvar->lv_type = vartype;
- else
- var_lvar->lv_type = item_type;
generate_STORE(cctx, ISN_STORE, var_lvar->lv_idx, NULL);
}