patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Problem: Vim9: "for" only accepts a list at compile time.
Solution: Also accept a list at runtime.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index ed069b7..db24eae 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6062,15 +6062,15 @@
return NULL;
}
- // now we know the type of "var"
+ // Now that we know the type of "var", check that it is a list, now or at
+ // runtime.
vartype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
- if (vartype->tt_type != VAR_LIST)
+ if (need_type(vartype, &t_list_any, -1, cctx) == FAIL)
{
- emsg(_("E1024: need a List to iterate over"));
drop_scope(cctx);
return NULL;
}
- if (vartype->tt_member->tt_type != VAR_ANY)
+ if (vartype->tt_type == VAR_LIST && vartype->tt_member->tt_type != VAR_ANY)
var_lvar->lv_type = vartype->tt_member;
// "for_end" is set when ":endfor" is found