Skip to content

MethodError hint offers no useful information in common case #53575

@LilithHafner

Description

@LilithHafner

In 1.10,

julia> f(x::Int) = x
f (generic function with 1 method)

julia> f(1.0)
ERROR: MethodError: no method matching f(::Float64)

Closest candidates are:
  f(::Int64)
   @ Main REPL[1]:1

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

Whereas in 1.11.0-alpha1 (after #47369), we have

julia> f(x::Int) = x
f (generic function with 1 method)

julia> f(1.0)
ERROR: MethodError: no method matching f(::Float64)
The function `f` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  f(::Int64)
   @ Main REPL[1]:1

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

The error message already displays function signatures that do exist and already says that no method matches the argument types (by providing the argument types). The hint has a lower information density and provides not additional information or explanation that was previously lacking. I do not think it is worth deferring the method signatures and stacktrace by one line to display this hint.

Most of #47369 is great, but I think some or all of the extra hints should be reverted.

cc @apaz-cli @vtjnash

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions