summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-04 11:36:51 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-04 11:36:51 +0000
commit46950b225fab2e10245a04952b2c238e0362e1b7 (patch)
tree1bdb4e4bc41fead52bd426354b1440c29e0c2d0d
parent972db232795874c58b9fdf23e43f53885a378eae (diff)
downloadvim-git-46950b225fab2e10245a04952b2c238e0362e1b7.tar.gz
patch 8.2.4295: Vim9: concatenating two lists may result in wrong typev8.2.4295
Problem: Vim9: concatenating two lists may result in wrong type. Solution: Remove the type instead of using list<any>. (closes #9692)
-rw-r--r--src/list.c5
-rw-r--r--src/testdir/test_vim9_expr.vim6
-rw-r--r--src/version.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/src/list.c b/src/list.c
index 3a6ea9766..578d6f115 100644
--- a/src/list.c
+++ b/src/list.c
@@ -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
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index a4e3e9e0f..cf4347c98 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 70d76d577..f11705dbc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4295,
+/**/
4294,
/**/
4293,