0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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.
This commit is contained in:
Bram Moolenaar
2020-07-05 21:38:11 +02:00
parent 67627355ac
commit 0ad3e894d7
4 changed files with 50 additions and 5 deletions

View File

@@ -6062,15 +6062,15 @@ compile_for(char_u *arg, cctx_T *cctx)
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