Help understand inference problem

in the MWE

using StaticArrays
flat_outer_product(f::F, a, b) where {F} = mapreduce(a -> map(b -> f(a, b), b), vcat, a)
a = SVector(1, 2)
b = SVector(2, 3)
@code_warntype flat_outer_product(SVector, a, b) # does not infer
@code_warntype flat_outer_product((a, b) -> SVector(a, b), a, b) # infers

the first call does not infer, the second does.

Is arity the problem? I thought it was implied by the way f was used. Can someone please explain what is going on?

Should I open an issue about this?

1 Like

AFAIU, the closure doesn’t specialize on Type, same as in:

julia> struct Foo{T}

julia> Foo(Int64)

Thanks! Is there a workaround here (for generic f?)