-
-
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 better "closest candidates" when there is a MethodError
#32470
Comments
I think we may want to have a modal in web contexts (click a button to get more info) and a similar mechanism in the repl (similar to the stack trace jumping) that prints this info. At that point, we could also use up a bit more vertical space to give users better info heuristically (right now it needs to be fairly compact since it prints on every method error, but if it's an opt in there's no such constraint). |
I often find the closest candidate list useful. Sure, the heuristics might need to be tweaked but it is very nice when you get one argument wrong, or transpose a set of arguments. |
Yes, I agree it's useful sometimes. I think the only question is whether we want to always print it by default or have an opt in way to get it (with then potentially more useful information). Or maybe the correct thing to do is to attempt to design those improved heuristics first and see if it actually needs more vertical space. |
What's the actual problem with the closest candidate list again? I haven't seen a single complaint about it for years.
I don't really understand this, if anything, the closest candidate list should be more useful for new users than for experienced ones. |
The complaint is that e.g.
is a scary thing to see for somebody who's never used the language before. |
Maybe, but users have the property of "has never used the language" for a quite short time. Then they become regular users. In my opinion, it is better to design things for regular users and instead write tutorials for new users to make them become regular users. But sure, even for regular users the closest candidate list sometimes has a low signal to noise ratio.
|
This old idea of mine might be a sensible path forward: #24299 My complaint about the closest candidate list is that it is often wholly unhelpful.
New users are more likely to experience the latter. |
For example, I'm just spitballing here without regard to compactness (or availability of information currently)
We'd need some way of explaining to the system whether or not it suggest the
|
(The idea here being that every type of suggestion is represented by a separate suggestion type, so there could be suggestions for:
And individual libraries could hook into this system to provide more intelligent suggestions (and potentially it's own suggestion types). #24299 that Matt referenced could go a long way in that direction. I think this kind of thing could be particularly useful for libraries. E.g. imagine Zygote using this to say something like |
Ideally, it would be nice for this mechanism to have two separate overloadable APIs: one for function author and one for type author (like
In this case, |
Or, maybe it does not have to be two separate APIs as the function/callable type is just the first type in the method signature (I'm thinking |
I think the following are good heuristics:
One thing that could help is to have the name of the arguments in addition to their type. But of course the worst problem by far is unions: the |
one minor change might be to hide the types for the arguments that match (the
Perhaps another option would be to print |
I wonder if a good rule for choosing which methods to show would be to assume the type of each argument is wrong one at a time and show the method that is most specific given the types of the other arguments? |
We should also apply a strict limit instead of printing |
On triage @Jameson brought up the idea that you could only print as much detail about a non-matching argument type as is required to make it not match. |
There are a couple of points around
MethodError
that we could improve from a user friendliness perspective. First, the closest candidates shown could be more specific to the error. Second, perhaps we don't want to show the closest candidates by default, and have a way for the user to ask for them.These are basically things that would greatly improve the experience for new users who may not be as well versed with the system just yet.
cc @JeffBezanson @Keno
The text was updated successfully, but these errors were encountered: