Mercurial > vim
changeset 27573:68eac9355e49 v8.2.4313
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 <Bram@vim.org>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 06 Feb 2022 19:45:02 +0100 |
parents | 42ce4f25bbda |
children | e436b6c8fe11 |
files | src/testdir/test_vim9_builtin.vim src/version.c src/vim9expr.c |
diffstat | 3 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -3626,6 +3626,7 @@ def Test_slice() var lds: list<dict<string>> = [{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))
--- 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,
--- 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 {