]> granicus.if.org Git - vim/commitdiff
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type v8.2.4295
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Feb 2022 11:36:51 +0000 (11:36 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Feb 2022 11:36:51 +0000 (11:36 +0000)
Problem:    Vim9: concatenating two lists may result in wrong type.
Solution:   Remove the type instead of using list<any>. (closes #9692)

src/list.c
src/testdir/test_vim9_expr.vim
src/version.c

index 3a6ea97668b36c9b53f1a5f3916ebdde042930ad..578d6f11554be8473f20ac85699d2d01d5957573 100644 (file)
@@ -1216,11 +1216,10 @@ list_copy(list_T *orig, int deep, int top, int copyID)
     copy = list_alloc();
     if (copy != NULL)
     {
-       if (orig->lv_type == NULL)
+       if (orig->lv_type == NULL || top || deep)
            copy->lv_type = NULL;
        else
-           copy->lv_type = alloc_type(top || deep
-                                                ? &t_list_any: orig->lv_type);
+           copy->lv_type = alloc_type(orig->lv_type);
        if (copyID != 0)
        {
            // Do this before adding the items, because one of the items may
index a4e3e9e0f27a7f8df38310fc52b4a3484478495a..cf4347c98c4984e674a6648fc17a6bf3053a8226 100644 (file)
@@ -1500,6 +1500,12 @@ def Test_expr5_list_add()
       assert_equal([[1, 2]], lln)
   END
   v9.CheckDefAndScriptSuccess(lines)
+
+  lines =<< trim END
+      var ln: list<number> = [0]
+      var lln: list<list<number>> = [ln + []]
+  END
+  v9.CheckDefAndScriptSuccess(lines)
 enddef
 
 " test multiply, divide, modulo
index 70d76d5773360578be7435441349bc9ad9d4a2a2..f11705dbcb68bd2ec58cded1143f149796906b85 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4295,
 /**/
     4294,
 /**/