]> granicus.if.org Git - vim/commitdiff
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop v8.2.3118
authorBram Moolenaar <Bram@vim.org>
Wed, 7 Jul 2021 19:55:25 +0000 (21:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Jul 2021 19:55:25 +0000 (21:55 +0200)
Problem:    Vim9: "any" type not handled correctly in for loop.
Solution:   Change compile time check into runtime check. (closes #8516)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 4abe4015ee01b1cf8fad5f961873dc918360bb1b..60f51a48c1fd523ef1c3aa9bfc6e37bf7c47c11d 100644 (file)
@@ -2488,6 +2488,12 @@ def Test_for_loop()
       endfor
       assert_equal('foobar', chars)
 
+      chars = ''
+      for x: string in {a: 'a', b: 'b'}->values()
+        chars ..= x
+      endfor
+      assert_equal('ab', chars)
+
       # unpack with type
       var res = ''
       for [n: number, s: string] in [[1, 'a'], [2, 'b']]
index e1774a4037480116025c83d75f7911b1d173e9f5..e080a2fa31c279e8bc02cd44ded426f77f225509 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3118,
 /**/
     3117,
 /**/
index 3a717e487fef222237be3b7539ed6ffe5a7acb7c..c1fc31ed23af5fac5733087652972c8615b79775 100644 (file)
@@ -7932,7 +7932,7 @@ compile_for(char_u *arg_start, cctx_T *cctx)
            if (lhs_type == &t_any)
                lhs_type = item_type;
            else if (item_type != &t_unknown
-                       && ((var_list && item_type == &t_any)
+                       && (item_type == &t_any
                          ? need_type(item_type, lhs_type,
                                                     -1, 0, cctx, FALSE, FALSE)
                          : check_type(lhs_type, item_type, TRUE, where))