# Multiple dispatch causes warntype in closure?

**URL:** https://discourse.julialang.org/t/multiple-dispatch-causes-warntype-in-closure/14029
**Category:** Performance
**Created:** [August 25, 2018, 8:04am UTC](https://discourse.julialang.org/t/multiple-dispatch-causes-warntype-in-closure/14029 "2018-08-25T08:04:29Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [August 26, 2018, 12:31am UTC](https://discourse.julialang.org/t/multiple-dispatch-causes-warntype-in-closure/14029/2 "2018-08-26T00:31:21Z")

</div>

It’s the same issue from this earlier topic you posted: [Strange @code\_warntype - #10 by kristoffer.carlsson](https://discourse.julialang.org/t/strange-code-warntype/14002/10)

You can work around the issue by explicitly capturing `f` in a `let` block:

```julia
julia> function generator1()::Function
           function f(x::Vector{Int64})
               return sum(x)
           end

           function f(x::Matrix{Int64})
               return prod(x)
           end

           g = let f_ = f
             function(xx)
               f_(xx) + 1
             end
           end

           return g
       end

```

---

_[View the full topic](https://discourse.julialang.org/t/multiple-dispatch-causes-warntype-in-closure/14029)._
