Open
Description
The docs say:
Apply the given function to every element of
arr
to form a new array then flatten the result. The argumentarr
must be an array or a string. Ifarr
is an array, functionfunc
must return an array. Ifarr
is a string, functionfunc
must return an string.
However, this is not enforced in all combinations. Example:
# Array input, function returns array, behaves as expected:
$ ./jsonnet -e 'std.flatMap(function(x) [x], ["a", "b", "c"])'
[
"a",
"b",
"c"
]
# Array input, function returns a string, behaves strangely:
$ ./jsonnet -e 'std.flatMap(function(x) x, ["a", "b", "c"])'
"[ ]abc"
Noticed while testing google/go-jsonnet#797