0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.3423: Vim9: list += list creates a new list in :def function

Problem:    Vim9: list += list creates a new list in :def function.
Solution:   Append to the existing list.
This commit is contained in:
Bram Moolenaar
2021-09-09 23:01:14 +02:00
parent efc084e335
commit 07802044b9
5 changed files with 36 additions and 12 deletions

View File

@@ -557,20 +557,21 @@ enddef
def Test_extend_list()
var lines =<< trim END
vim9script
var l: list<number>
l += [123]
assert_equal([123], l)
var l1: list<number>
var l2 = l1
assert_true(l1 is l2)
l1 += [123]
assert_equal([123], l1)
assert_true(l1 is l2)
END
CheckScriptSuccess(lines)
CheckDefAndScriptSuccess(lines)
lines =<< trim END
vim9script
var list: list<string>
extend(list, ['x'])
assert_equal(['x'], list)
END
CheckScriptSuccess(lines)
CheckDefAndScriptSuccess(lines)
# appending to NULL list from a function
lines =<< trim END