From 381692b6f1c2ec9b73a139500286ddc9347a1c01 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Feb 2022 20:01:27 +0000 Subject: patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy() Problem: Vim9: strict type checking after copy() and deepcopy(). Solution: Allow type to change after making a copy. (closes #9644) --- src/eval.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 076ba1fed..b5ccc4bdf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -6160,6 +6160,7 @@ handle_subscript( /* * Make a copy of an item. * Lists and Dictionaries are also copied. A deep copy if "deep" is set. + * "top" is TRUE for the toplevel of copy(). * For deepcopy() "copyID" is zero for a full copy or the ID for when a * reference to an already copied list/dict can be used. * Returns FAIL or OK. @@ -6169,6 +6170,7 @@ item_copy( typval_T *from, typval_T *to, int deep, + int top, int copyID) { static int recurse = 0; @@ -6207,7 +6209,8 @@ item_copy( ++to->vval.v_list->lv_refcount; } else - to->vval.v_list = list_copy(from->vval.v_list, deep, copyID); + to->vval.v_list = list_copy(from->vval.v_list, + deep, top, copyID); if (to->vval.v_list == NULL) ret = FAIL; break; @@ -6226,7 +6229,8 @@ item_copy( ++to->vval.v_dict->dv_refcount; } else - to->vval.v_dict = dict_copy(from->vval.v_dict, deep, copyID); + to->vval.v_dict = dict_copy(from->vval.v_dict, + deep, top, copyID); if (to->vval.v_dict == NULL) ret = FAIL; break; -- cgit v1.2.1