-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Partial parameter match leads to confusing MethodError #18110
Comments
This situation is much less straightforward than #17319, since all parameters do occur in the signature and the method is indeed callable with some arguments. For this we'd need to compute whether there exists a type that can be determined to be a subtype of the signature without matching all of the static parameters. It seems like a pretty non-trivial problem to me. |
I think the easiest thing to do here (after #8974) will be to detect this situation in the MethodError printer and report that |
Is this more similar to #3738 ? |
It's related, but those were cases where the method should have matched (and now does), while this is a case where the method (correctly) won't match and better tooling is needed. |
It's probably mostly a lack of imagination on my part, but I'm having a hard time seeing how this would arise outside of the context of Or is the problem multi-argument functions, where some parameters may be fixed by the first argument, others by the second, and only certain combinations that fail to fix all of them? |
Fixed by #23117 |
This is closely related to #17319, but distinct enough that I think it deserves its own issue.
Here's the problem:
Note that there's no red highlighting, which suggests that the arguments match (except they don't). Eventually you figure out that this happens because
T
is not a parameter ofFoo
. You can work around this by instead definingbut a newbie will not discover this easily.
EDIT: in particular, unlike #17319 there is no warning given. At a minimum, the lack of a warning is a bug.
The text was updated successfully, but these errors were encountered: