mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
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)
This commit is contained in:
@@ -3626,6 +3626,7 @@ def Test_slice()
|
|||||||
|
|
||||||
var lds: list<dict<string>> = [{key: 'value'}]
|
var lds: list<dict<string>> = [{key: 'value'}]
|
||||||
assert_equal(['val'], lds->slice(0, 1)->map((_, v) => 'val'))
|
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(0z1122334455, slice(0z001122334455, 1))
|
||||||
assert_equal(0z112233, slice(0z001122334455, 1, 4))
|
assert_equal(0z112233, slice(0z001122334455, 1, 4))
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4313,
|
||||||
/**/
|
/**/
|
||||||
4312,
|
4312,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -182,6 +182,9 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
|
|||||||
vartype == VAR_LIST ? ISN_LISTSLICE : ISN_ANYSLICE,
|
vartype == VAR_LIST ? ISN_LISTSLICE : ISN_ANYSLICE,
|
||||||
2) == FAIL)
|
2) == FAIL)
|
||||||
return 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
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user