-
-
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
add hasmethod_n
intrinsic to check for the existance of n
argument methods for a function.
#56279
Comments
This result seems like bug: it probably should have returned false, since Julia may assume that the method list queries obeys subtyping transitivity, while that method cannot be called / does not exist for all supertypes of the input query. That is a bug in v1.9 though, and gets fixed (not a regression) in v1.10. |
What supertype can it not be called for? |
Not that I understand what's going on here, though. |
But that's also true for: julia> g(::Union{Int,Float64}) = 13
julia> hasmethod(g, Tuple{Int})
true
I thought that |
Is the disagreement about whether |
Ah right. Maybe the issue is that it may return false because it determines is ambiguous which method to (not) call, so it would be wrong to ever use as an approximation of whether a method exists with that number of arguments? |
Covered by exactly one method is the actual definition of this query, since that is the definition used by invoke, and this does the same query as invoke during runtime (during inference, it does the same query also as invoke, including first discarding the possibility of any parameter being Union{}) |
One resolution for this would be a new |
Right, I see - this is emulating I don't think inhabited-ness is doing any work in that definition though TBH. The query over uninhabited types still seems reasonable to me (is there a most-specific, covering method) - I don't see where we discard any uninhabited parameter types? Of course, that's assuming that #54792 lands one day and not all uninhabited types are type-equal to
That's true - it seems like you'd want to throw out specificity and just check for covering methods for the query @oscardssmith wants |
With the following example, I do think a
|
This approach would be much clearer, as |
Should this issue be renamed to a request for |
Tuple{Union{}}
makes hasmethod
less powerful.hasmethod_n
intrinsic to check for the existance of n
argument methods for a function.
In 1.9: it was possible to qurery the method table to see whether a given function has a 2 argument method: e.g.
However on 1.10, we can't express
Tuple{Union{}, Union{}}
so we can't express it like this (instead you have to do something like searching through allmethods
which can't be done at compile-time.This is closely related to #52385, but IMO is sufficiently different to be worth separating into a separate issue.
The text was updated successfully, but these errors were encountered: