0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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)
This commit is contained in:
Bram Moolenaar
2021-07-07 21:55:25 +02:00
parent efc5db5215
commit 5ede5b231e
3 changed files with 9 additions and 1 deletions

View File

@@ -2488,6 +2488,12 @@ def Test_for_loop()
endfor endfor
assert_equal('foobar', chars) assert_equal('foobar', chars)
chars = ''
for x: string in {a: 'a', b: 'b'}->values()
chars ..= x
endfor
assert_equal('ab', chars)
# unpack with type # unpack with type
var res = '' var res = ''
for [n: number, s: string] in [[1, 'a'], [2, 'b']] for [n: number, s: string] in [[1, 'a'], [2, 'b']]

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3118,
/**/ /**/
3117, 3117,
/**/ /**/

View File

@@ -7932,7 +7932,7 @@ compile_for(char_u *arg_start, cctx_T *cctx)
if (lhs_type == &t_any) if (lhs_type == &t_any)
lhs_type = item_type; lhs_type = item_type;
else if (item_type != &t_unknown else if (item_type != &t_unknown
&& ((var_list && item_type == &t_any) && (item_type == &t_any
? need_type(item_type, lhs_type, ? need_type(item_type, lhs_type,
-1, 0, cctx, FALSE, FALSE) -1, 0, cctx, FALSE, FALSE)
: check_type(lhs_type, item_type, TRUE, where)) : check_type(lhs_type, item_type, TRUE, where))