I have a program that I believe should compile but does not.
```
[
"one",
"two",
].map(k, state[k].map(e, {
k: e,
})).flatten().map(d, d.with({
"aye": state.aye,
"bee": state.bee,
}))
```
The two helpers' types in this program are defined with the following
Go:
```
cel.Function("flatten",
cel.MemberOverload(
"list_flatten",
[]*cel.Type{listV},
listV,
cel.UnaryBinding(flatten),
),
),
cel.Function("with",
cel.MemberOverload(
"map_with_map",
[]*cel.Type{mapKV, mapKV},
mapKV,
cel.BinaryBinding(withAll),
),
),
```
and
```
var (
typeV = cel.TypeParamType("V")
typeK = cel.TypeParamType("K")
mapKV = cel.MapType(typeK, typeV)
listV = cel.ListType(typeV)
)
``
Output for the bad program:
```
bad: failed compilation: ERROR: <input>:7:28: found no matching
overload for 'with' applied to 'list(map(string, dyn)).(map(string,
dyn))'
| })).flatten().map(d, d.with({
| ...........................^
exit status 1
``
The program is not the most efficient approach (and the more efficient
approach does work), but it was surprising to me that it did not work;
`flatten` returns a list or objects and `with` accepts an object, but
the error is complaining that `d` is a list. Removing the `.with…`
shows this is not the case, as does injecting type debugging into the
runtime.
Have I missed something or is this a type checking failure?
A self contained repro for this is here
https://go.dev/play/p/7KBvbCXNcnW (will need to be downloaded due to
playground time limits).
thanks
Dan