diff src/vim9compile.c @ 25162:c44d6ac81c42 v8.2.3117

patch 8.2.3117: Vim9: type not properly checked in for loop Commit: https://github.com/vim/vim/commit/efc5db5215b4efc424b2de34613525d729a05c93 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 7 21:21:30 2021 +0200 patch 8.2.3117: Vim9: type not properly checked in for loop Problem: Vim9: type not properly checked in for loop. Solution: Have items() return a list of lists. Add runtime type checks. (closes #8515)
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Jul 2021 21:30:03 +0200
parents 18b31f0a4bb5
children 0e08e34fa0b8
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -7932,8 +7932,11 @@ compile_for(char_u *arg_start, cctx_T *c
 	    if (lhs_type == &t_any)
 		lhs_type = item_type;
 	    else if (item_type != &t_unknown
-		       && !(var_list && item_type == &t_any)
-		       && check_type(lhs_type, item_type, TRUE, where) == FAIL)
+			&& ((var_list && item_type == &t_any)
+			  ? need_type(item_type, lhs_type,
+						     -1, 0, cctx, FALSE, FALSE)
+			  : check_type(lhs_type, item_type, TRUE, where))
+			== FAIL)
 		goto failed;
 	    var_lvar = reserve_local(cctx, arg, varlen, TRUE, lhs_type);
 	    if (var_lvar == NULL)