From: Bram Moolenaar Date: Thu, 3 Feb 2022 21:47:34 +0000 (+0000) Subject: patch 8.2.4293: Vim9: when copying a list it gets type list X-Git-Tag: v8.2.4293 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7676c158798a7c90f500cab2c12af0d47bad6026;p=thirdparty%2Fvim.git patch 8.2.4293: Vim9: when copying a list it gets type list Problem: Vim9: when copying a list it gets type list even when the original list did not have a type. Solution: Only set the type when the original list has a type. (closes #9692) --- diff --git a/src/list.c b/src/list.c index 86c16793f9..3a6ea97668 100644 --- a/src/list.c +++ b/src/list.c @@ -1216,7 +1216,11 @@ list_copy(list_T *orig, int deep, int top, int copyID) copy = list_alloc(); if (copy != NULL) { - copy->lv_type = alloc_type(top || deep ? &t_list_any: orig->lv_type); + if (orig->lv_type == NULL) + copy->lv_type = NULL; + else + 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 diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index c6466d39a0..a4e3e9e0f2 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1495,6 +1495,9 @@ def Test_expr5_list_add() # result of glob() is "any", runtime type check var sl: list = glob('*.txt', false, true) + [''] + + var lln: list> = [[1] + [2]] + assert_equal([[1, 2]], lln) END v9.CheckDefAndScriptSuccess(lines) enddef diff --git a/src/version.c b/src/version.c index 04199782e1..5140eb9520 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4293, /**/ 4292, /**/