# Help understand inference problem

**URL:** <https://discourse.julialang.org/t/help-understand-inference-problem/38888>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 6, 2020, 2:03pm UTC](https://discourse.julialang.org/t/help-understand-inference-problem/38888 "2020-05-06T14:03:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 6, 2020, 2:03pm UTC](https://discourse.julialang.org/t/help-understand-inference-problem/38888/1 "2020-05-06T14:03:36Z")

</div>

in the MWE

```julia
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?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 6, 2020, 2:25pm UTC](https://discourse.julialang.org/t/help-understand-inference-problem/38888/2 "2020-05-06T14:25:19Z")

</div>

[https://github.com/JuliaLang/julia/issues/23618](https://github.com/JuliaLang/julia/issues/23618)

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

```julia
julia> struct Foo{T}
       v::T
       end

julia> Foo(Int64)
Foo{DataType}(Int64)

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 6, 2020, 2:33pm UTC](https://discourse.julialang.org/t/help-understand-inference-problem/38888/3 "2020-05-06T14:33:02Z")

</div>

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