# Why is this a matching error?

**URL:** <https://discourse.julialang.org/t/why-is-this-a-matching-error/56882>\
**Category:** General Usage\
**Created:** [March 10, 2021, 1:43pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882 "2021-03-10T13:43:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [March 10, 2021, 1:43pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882/1 "2021-03-10T13:43:17Z")

</div>

Hi,

I’m facing this matching error but I simply don’t see why this is not matching…

```julia
pull!(item, item2 => 10)
MethodError: no method matching pull!(::Item{Float64,Dirac{Float64},linear_holding_cost{Float64}}, ::Pair{Item{Float64,Dirac{Float64},linear_holding_cost{Int64}},Int64})
  Closest candidates are:
    pull!(::Item, !Matched::Pair{Any,Number}) at /home/dehaybe/Documents/Doctorat/InventoryModels/src/item.jl:36

```

---

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [March 10, 2021, 1:45pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882/2 "2021-03-10T13:45:42Z")

</div>

Oh no okay I get it, the pull! function should be `pull!(::Item, Pair{<:Any, <:Number})`.  
I keep forgetting about that. Maybe the error message could be a bit more guiding ? 🧐

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [March 10, 2021, 2:05pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882/3 "2021-03-10T14:05:42Z")

</div>

Agreed - the problem is that the error message can’t distinguish between mistyped function declarations and “real” mismatch due to some type instability/missing method, so the message should guide to at least those two possibilities. It’s been a topic before, but I can’t seem to find the relevant issue on github.

---

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [March 10, 2021, 2:06pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882/4 "2021-03-10T14:06:49Z")

</div>

I guess this must not be a trivial thing to improve 😕

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [March 10, 2021, 2:14pm UTC](https://discourse.julialang.org/t/why-is-this-a-matching-error/56882/5 "2021-03-10T14:14:08Z")

</div>

Any message improvement is better than none! In fact, `MethodError` has been one of the worst offenders in terms of communicating what’s wrong. If it’s only meant to guide towards potential solutions, I think it’ll have an easier time to be merged, compared to trying to fix all possible cases.

If the formulation is sufficiently suggestive (and _not_ definitive), it’d be very much appreciated. Maybe something like

```julia
Potential solutions are:
  * Missing method definition
  * Too strong limitation on argument types
  * Unexpected type at called function

```

would be a good start for a brainstorming session.
