comparison src/vim9compile.c @ 21188:d73b6ba20053 v8.2.1145

patch 8.2.1145: Vim9: "for" only accepts a list at compile time Commit: https://github.com/vim/vim/commit/0ad3e894d75236915e67dfbbcc821b6bb3c05d91 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 5 21:38:11 2020 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jul 2020 21:45:04 +0200
parents 96ae8622cfb6
children afed2045ffc9
comparison
equal deleted inserted replaced
21187:bfc9b0a72673 21188:d73b6ba20053
6060 { 6060 {
6061 drop_scope(cctx); 6061 drop_scope(cctx);
6062 return NULL; 6062 return NULL;
6063 } 6063 }
6064 6064
6065 // now we know the type of "var" 6065 // Now that we know the type of "var", check that it is a list, now or at
6066 // runtime.
6066 vartype = ((type_T **)stack->ga_data)[stack->ga_len - 1]; 6067 vartype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
6067 if (vartype->tt_type != VAR_LIST) 6068 if (need_type(vartype, &t_list_any, -1, cctx) == FAIL)
6068 { 6069 {
6069 emsg(_("E1024: need a List to iterate over"));
6070 drop_scope(cctx); 6070 drop_scope(cctx);
6071 return NULL; 6071 return NULL;
6072 } 6072 }
6073 if (vartype->tt_member->tt_type != VAR_ANY) 6073 if (vartype->tt_type == VAR_LIST && vartype->tt_member->tt_type != VAR_ANY)
6074 var_lvar->lv_type = vartype->tt_member; 6074 var_lvar->lv_type = vartype->tt_member;
6075 6075
6076 // "for_end" is set when ":endfor" is found 6076 // "for_end" is set when ":endfor" is found
6077 scope->se_u.se_for.fs_top_label = instr->ga_len; 6077 scope->se_u.se_for.fs_top_label = instr->ga_len;
6078 6078