diff --git a/src/dict.c b/src/dict.c index 06f38716b5..c2dc6a7c23 100644 --- a/src/dict.c +++ b/src/dict.c @@ -306,7 +306,10 @@ dict_copy(dict_T *orig, int deep, int top, int copyID) orig->dv_copyID = copyID; orig->dv_copydict = copy; } - copy->dv_type = alloc_type(top || deep ? &t_dict_any : orig->dv_type); + if (orig->dv_type == NULL || top || deep) + copy->dv_type = NULL; + else + copy->dv_type = alloc_type(orig->dv_type); todo = (int)orig->dv_hashtab.ht_used; for (hi = orig->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi) diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index f7a5006b45..6e53d270f1 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -745,6 +745,9 @@ def Test_copy_return_type() var ndd: dict> = {a: {x: 1, y: 2}} assert_equal({x: 1, y: 2, z: 'x'}, ndd->deepcopy()['a']->extend({z: 'x'})) + + var ldn: list> = [{a: 0}]->deepcopy() + assert_equal([{a: 0}], ldn) enddef def Test_count() diff --git a/src/version.c b/src/version.c index b9945845d5..84ab4092ec 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 */ +/**/ + 4301, /**/ 4300, /**/