Mercurial > vim
changeset 27535:e2bb28237695 v8.2.4295
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Commit: https://github.com/vim/vim/commit/46950b225fab2e10245a04952b2c238e0362e1b7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 4 11:36:51 2022 +0000
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Problem: Vim9: concatenating two lists may result in wrong type.
Solution: Remove the type instead of using list<any>. (closes https://github.com/vim/vim/issues/9692)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Feb 2022 12:45:03 +0100 |
parents | 77f6bef22e25 |
children | de1ec574cab2 |
files | src/list.c src/testdir/test_vim9_expr.vim src/version.c |
diffstat | 3 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/list.c +++ b/src/list.c @@ -1216,11 +1216,10 @@ list_copy(list_T *orig, int deep, int to 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
--- 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