-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show closest matching methods on MethodError #7686
Comments
There are no implicit conversions in Julia method dispatch, and with multiple dispatch which argument doesn't match is not always well-defined. For example, given: f(x::Float64, y::Float64) = ...
f(x::Int, y::Int) = ... which argument doesn't match for |
closing as dup of #7512. |
I'm working on my idea I descriped here: #7512 (comment) |
Great! I'm not yet totally convinced, because I can't really see how you can add much value by ordering the methods differently than There is already (#4957) about colorizing the terminal display of a |
I'm using many typealiases and functions with a long signature. When I run into |
Ok, the problem definitely changes when you have long signatures and typealiases. Maybe we could use custom ordering and some sort of equality highlighting when the missing method has 3 or more arguments? |
Isn't that what I suggested in #7512 (comment)? |
As far as I can tell, your |
Okay apart from only displaying it when the method has 3 or more arguments ;) |
Okay I've created a first patch which implements my idea. It's still very dirty and sorting isn't implemented. But apart from that it works :) |
You can redefine functions, so if you have a file # replhack.jl
function Base.showerror(io::IO, e::MethodError)
# snip method content.
end
#testing
try
foo(0,0)
catch e
Base.showerror(STDIN, e)
end When you are finished, you can copy the code into the In this case the important thing is actually just to create a function that takes |
You should also work on the latest master, as I changed this method when I merged #7688 earlier today. It will luckily be easy to copy your changes on top of mine. |
Thanks! I've used your I rebased against master and created a pull request :) |
Hi! Often I run into
no method matching
errors without knowing what I'm passing wrong. To demonstrate with an example:The error doesn't tell me which argument can't be implicitly converted.
The following in C gives me a better error message:
The text was updated successfully, but these errors were encountered: