From: Bram Moolenaar Date: Wed, 7 Jul 2021 19:55:25 +0000 (+0200) Subject: patch 8.2.3118: Vim9: "any" type not handled correctly in for loop X-Git-Tag: v8.2.3118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ede5b231eb2269b0ef335f3cd24e4c4b1d4395b;p=vim patch 8.2.3118: Vim9: "any" type not handled correctly in for loop Problem: Vim9: "any" type not handled correctly in for loop. Solution: Change compile time check into runtime check. (closes #8516) --- diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 4abe4015e..60f51a48c 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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']] diff --git a/src/version.c b/src/version.c index e1774a403..e080a2fa3 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3118, /**/ 3117, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 3a717e487..c1fc31ed2 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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))