# Remove additional rule that parameters must match for dispatch

**URL:** <https://discourse.julialang.org/t/remove-additional-rule-that-parameters-must-match-for-dispatch/11482>\
**Category:** General Usage\
**Created:** [June 6, 2018, 6:52pm UTC](https://discourse.julialang.org/t/remove-additional-rule-that-parameters-must-match-for-dispatch/11482 "2018-06-06T18:52:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [June 6, 2018, 6:52pm UTC](https://discourse.julialang.org/t/remove-additional-rule-that-parameters-must-match-for-dispatch/11482/1 "2018-06-06T18:52:51Z")

</div>

[https://github.com/JuliaLang/julia/pull/23117](https://github.com/JuliaLang/julia/pull/23117)

Can someone tell what this change brings?

Can you show me an example what it enabled?

Thanks

---

<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:** [June 6, 2018, 7:47pm UTC](https://discourse.julialang.org/t/remove-additional-rule-that-parameters-must-match-for-dispatch/11482/2 "2018-06-06T19:47:22Z")

</div>

In Julia v0.6, this doesn’t work:

```julia
julia> f(x::Union{Symbol, Vector{T}}) where {T} = "hello"
f (generic function with 1 method)

julia> f(:foo)
ERROR: MethodError: no method matching f(::Symbol)
Closest candidates are:
  f(::Union{Array{T,1}, Symbol}) where T at REPL[1]:1

```

because Julia v0.6 required that the parameter `T` must be defined by the type of the function arguments (in this case, `x::Symbol`). . When you pass a `Symbol` as `x`, though, `T` is not defined and the method doesn’t match, even though it should work just fine for a `Symbol` argument.

In Julia v0.7 this requirement is removed:

```julia
julia> f(x::Union{Symbol, Vector{T}}) where {T} = "hello"
f (generic function with 1 method)

julia> f(:foo)
"hello"

```

and the function will work, as long as you don’t actually use the value of `T` (since it’s still not defined when `x` is a `Symbol`).

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [June 6, 2018, 8:27pm UTC](https://discourse.julialang.org/t/remove-additional-rule-that-parameters-must-match-for-dispatch/11482/3 "2018-06-06T20:27:16Z")

</div>

FWIW I’ve run into this limitation on a real project. See [Understanding the use of Union with parametric types](https://discourse.julialang.org/t/understanding-the-use-of-union-with-parametric-types/337) for a brief discussion. I didn’t know the issue had been addressed. That’s cool!
