Request for: examples of unhelpful selection of `Closest candidates` on a `MethodError`

I’m experimenting with the shortlisting algorithm used to select the list of suggested methods when a MethodError is hit. As I’m sure many of us have experienced, sometimes the suggested methods are in fact not at all related to the “true” most relevant.

I would love any kind of examples along these lines of a time that you encountered a MethodError but the closest candidates list was, in your subjective opinion, poorly selected! Any kind of packages, contexts, complexity, etc. are welcome. If possible, ideally make the MWE something I can reproduce myself :slight_smile:

I’m most frequently annoyed by it in cases where it’s just not a supported operation in the first place. Things like:

julia> Int(Day(1))
ERROR: MethodError: no method matching Int64(::Day)
The type `Int64` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Int64(::Float64)
   @ Base float.jl:990
  Int64(::Float32)
   @ Base float.jl:990
  Int64(::Float16)
   @ Base float.jl:990
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[6]:1

julia> convert(Int, Day(1))
ERROR: MethodError: Cannot `convert` an object of type Day to an object of type Int64
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  convert(::Type{T}, ::T) where T<:Number
   @ Base number.jl:6
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:126
  convert(::Type{T}, ::Number) where T<:Number
   @ Base number.jl:7
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

Maybe that’s a different class than you’re after, though.