# HG changeset patch # User Bram Moolenaar # Date 1644173102 -3600 # Node ID 68eac9355e493e6d7a36a91852a7742b07c8cef5 # Parent 42ce4f25bbdafac58ae09ca6aa5fefab27af9a6c patch 8.2.4313: Vim9: cannot change type of list after making a slice Commit: https://github.com/vim/vim/commit/5f4ef5f5e5529c147c2274cd0f6416e2546d6fc7 Author: Bram Moolenaar Date: Sun Feb 6 18:36:53 2022 +0000 patch 8.2.4313: Vim9: cannot change type of list after making a slice Problem: Vim9: cannot change type of list after making a slice. Solution: Adjust the declared member type. (closes https://github.com/vim/vim/issues/9696) diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -3626,6 +3626,7 @@ def Test_slice() var lds: list> = [{key: 'value'}] assert_equal(['val'], lds->slice(0, 1)->map((_, v) => 'val')) + assert_equal(['val'], lds[ : ]->map((_, v) => 'val')) assert_equal(0z1122334455, slice(0z001122334455, 1)) assert_equal(0z112233, slice(0z001122334455, 1, 4)) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4313, +/**/ 4312, /**/ 4311, diff --git a/src/vim9expr.c b/src/vim9expr.c --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -182,6 +182,9 @@ compile_member(int is_slice, int *keepin vartype == VAR_LIST ? ISN_LISTSLICE : ISN_ANYSLICE, 2) == FAIL) return FAIL; + // a copy is made so the member type is no longer declared + if (typep->type_decl->tt_type == VAR_LIST) + typep->type_decl = &t_list_any; } else {