patch 8.2.4587: Vim9: double free after unpacking a list
Problem: Vim9: double free after unpacking a list.
Solution: Make a copy of the value instead of moving it. (closes #9968)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 94aa1e9..c94f298 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -2253,6 +2253,13 @@
res->add(n)
endfor
assert_equal([2, 5], res)
+
+ var text: list<string> = ["hello there", "goodbye now"]
+ var splitted = ''
+ for [first; next] in mapnew(text, (i, v) => split(v))
+ splitted ..= string(first) .. string(next) .. '/'
+ endfor
+ assert_equal("'hello'['there']/'goodbye'['now']/", splitted)
END
v9.CheckDefAndScriptSuccess(lines)