patch 8.2.2449: Vim9: flatten() always changes the list type
Problem: Vim9: flatten() always changes the list type.
Solution: Disallow using flatten() and add flattennew().
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1c4f46e..8bab492 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2549,6 +2549,8 @@
findfile({name} [, {path} [, {count}]])
String find file {name} in {path}
flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels
+flattennew({list} [, {maxdepth}])
+ List flatten a copy of {list}
float2nr({expr}) Number convert Float {expr} to a Number
floor({expr}) Float round {expr} down
fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2}
@@ -4712,8 +4714,10 @@
Flatten {list} up to {maxdepth} levels. Without {maxdepth}
the result is a |List| without nesting, as if {maxdepth} is
a very large number.
- The {list} is changed in place, make a copy first if you do
+ The {list} is changed in place, use |flattennew()| if you do
not want that.
+ In Vim9 script flatten() cannot be used, you must always use
+ |flattennew()|.
*E900*
{maxdepth} means how deep in nested lists changes are made.
{list} is not modified when {maxdepth} is 0.
@@ -4727,6 +4731,10 @@
:echo flatten([1, [2, [3, 4]], 5], 1)
< [1, 2, [3, 4], 5]
+flattennew({list} [, {maxdepth}]) *flattennew()*
+ Like |flatten()| but first make a copy of {list}.
+
+
float2nr({expr}) *float2nr()*
Convert {expr} to a Number by omitting the part after the
decimal point.
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 965a977..98e9a10 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -665,6 +665,7 @@
count() count number of times a value appears in a List
repeat() repeat a List multiple times
flatten() flatten a List
+ flattennew() flatten a copy of a List
Dictionary manipulation: *dict-functions*
get() get an entry without an error for a wrong key