summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-07 21:55:25 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-07 21:55:25 +0200
commit5ede5b231eb2269b0ef335f3cd24e4c4b1d4395b (patch)
treedc606ceb6f956d515241ee521971fb63d86005fa /src
parentefc5db5215b4efc424b2de34613525d729a05c93 (diff)
patch 8.2.3118: Vim9: "any" type not handled correctly in for loopv8.2.3118
Problem: Vim9: "any" type not handled correctly in for loop. Solution: Change compile time check into runtime check. (closes #8516)
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_script.vim6
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 4abe4015ee..60f51a48c1 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 e1774a4037..e080a2fa31 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3118,
+/**/
3117,
/**/
3116,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 3a717e487f..c1fc31ed23 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))