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)
diff --git a/src/list.c b/src/list.c
index ff7d5ab..86c1679 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1015,7 +1015,7 @@
 
     if (make_copy)
     {
-	l = list_copy(l, TRUE, get_copyID());
+	l = list_copy(l, TRUE, TRUE, get_copyID());
 	rettv->vval.v_list = l;
 	if (l == NULL)
 	    return;
@@ -1102,7 +1102,7 @@
     if (l1 == NULL)
 	l = list_alloc();
     else
-	l = list_copy(l1, FALSE, 0);
+	l = list_copy(l1, FALSE, TRUE, 0);
     if (l == NULL)
 	return FAIL;
     tv->v_type = VAR_LIST;
@@ -1200,11 +1200,11 @@
 /*
  * Make a copy of list "orig".  Shallow if "deep" is FALSE.
  * The refcount of the new list is set to 1.
- * See item_copy() for "copyID".
+ * See item_copy() for "top" and "copyID".
  * Returns NULL when out of memory.
  */
     list_T *
-list_copy(list_T *orig, int deep, int copyID)
+list_copy(list_T *orig, int deep, int top, int copyID)
 {
     list_T	*copy;
     listitem_T	*item;
@@ -1216,7 +1216,7 @@
     copy = list_alloc();
     if (copy != NULL)
     {
-	copy->lv_type = alloc_type(orig->lv_type);
+	copy->lv_type = alloc_type(top || deep ? &t_list_any: orig->lv_type);
 	if (copyID != 0)
 	{
 	    // Do this before adding the items, because one of the items may
@@ -1233,7 +1233,8 @@
 		break;
 	    if (deep)
 	    {
-		if (item_copy(&item->li_tv, &ni->li_tv, deep, copyID) == FAIL)
+		if (item_copy(&item->li_tv, &ni->li_tv,
+						  deep, FALSE, copyID) == FAIL)
 		{
 		    vim_free(ni);
 		    break;
@@ -2701,11 +2702,11 @@
     }
     l2 = argvars[1].vval.v_list;
     if ((is_new || !value_check_lock(l1->lv_lock, arg_errmsg, TRUE))
-	    && l2 != NULL)
+								 && l2 != NULL)
     {
 	if (is_new)
 	{
-	    l1 = list_copy(l1, FALSE, get_copyID());
+	    l1 = list_copy(l1, FALSE, TRUE, get_copyID());
 	    if (l1 == NULL)
 		return;
 	}