From: Bram Moolenaar Date: Sun, 6 Feb 2022 18:36:53 +0000 (+0000) Subject: patch 8.2.4313: Vim9: cannot change type of list after making a slice X-Git-Tag: v8.2.4313 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f4ef5f5e5529c147c2274cd0f6416e2546d6fc7;p=vim 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 #9696) --- diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index ee32b3989..3ad6e0e62 100644 --- 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 index 825f12da3..7dbefa49f 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4313, /**/ 4312, /**/ diff --git a/src/vim9expr.c b/src/vim9expr.c index 146e136bd..402803768 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -182,6 +182,9 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx) 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 {