summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-05 14:05:51 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-05 14:05:51 +0000
commite0c2b2ceaa8ca2d0f412f17f4cf14fb4f7a3296f (patch)
treeaaf24425b3e4d43316647169685b66b5df3e8bf5
parent4fa1346bf4210747f34b64d05b39309918ca538d (diff)
patch 8.2.4301: Vim9: type error for copy of dictv8.2.4301
Problem: Vim9: type error for copy of dict. Solution: Do not use dict<any> but no type. (closes #9696)
-rw-r--r--src/dict.c5
-rw-r--r--src/testdir/test_vim9_builtin.vim3
-rw-r--r--src/version.c2
3 files changed, 9 insertions, 1 deletions
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<dict<number>> = {a: {x: 1, y: 2}}
assert_equal({x: 1, y: 2, z: 'x'}, ndd->deepcopy()['a']->extend({z: 'x'}))
+
+ var ldn: list<dict<number>> = [{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
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4301,
+/**/
4300,
/**/
4299,