summaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/list.c b/src/list.c
index ff7d5ab9ba..86c16793f9 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1015,7 +1015,7 @@ flatten_common(typval_T *argvars, typval_T *rettv, int make_copy)
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 @@ list_concat(list_T *l1, list_T *l2, typval_T *tv)
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 @@ list_slice_or_index(
/*
* 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 @@ list_copy(list_T *orig, int deep, int copyID)
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 @@ list_copy(list_T *orig, int deep, int copyID)
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 @@ list_extend_func(
}
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;
}