Mercurial > vim
changeset 25164:0e08e34fa0b8 v8.2.3118
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Commit: https://github.com/vim/vim/commit/5ede5b231eb2269b0ef335f3cd24e4c4b1d4395b
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 7 21:55:25 2021 +0200
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 https://github.com/vim/vim/issues/8516)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 07 Jul 2021 22:00:04 +0200 |
parents | 0fc3365fc931 |
children | 166e1c1ad0c9 |
files | src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c |
diffstat | 3 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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']]
--- 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,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7932,7 +7932,7 @@ 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) + && (item_type == &t_any ? need_type(item_type, lhs_type, -1, 0, cctx, FALSE, FALSE) : check_type(lhs_type, item_type, TRUE, where))