std.map does not take string as input
Duologic opened this issue · 2 comments
In upstream jsonnet, std.map
accept strings as input, this is useful when parsing strings. Interestingly it works for std.mapWithIndex
in jrsonnet but not for std.map
.
std.map(function(x) x, 'string')
Expected result:
[
"s",
"t",
"r",
"i",
"n",
"g"
]
Actual result:
type error: expected array, got string
argument <arr> evaluation
a.jsonnet:25:1-34: function <builtin_map> call
Why I mark this issue as an enhancement:
In the Jsonnet standard library, many functions don't have their argument types specified and, in reality, work with more things than some may expect.
I.e. there is std.xor
/std.xnor
, and those functions "work" with strings, which doesn't make much sense: std.xor("a", "b"), std.xnor("c", "c")
.
When porting such functions to Jrsonnet, I speculate on accepted types; in this case, it only supports arrays now.
In cases when speculated types are not compatible with what the user expects, I fix it.
No worries, I'm just trying out jrsonnet on different code bases, this also means it comes across all kinds of Jsonnet features.
From my surface level knowledge, I understand that Jsonnet sees all these arguments as 'expressions', regardless of the type.