Skip to content
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

Bug in hasmethod(f, Tuple{Union{}}) #30808

Closed
ettersi opened this issue Jan 23, 2019 · 2 comments
Closed

Bug in hasmethod(f, Tuple{Union{}}) #30808

ettersi opened this issue Jan 23, 2019 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@ettersi
Copy link
Contributor

ettersi commented Jan 23, 2019

The following should be true:

julia> hasmethod((::Int)->nothing, Tuple{Union{}})
false

Note that hasmethod() works as expected if the function is defined in terms of an abstract type.

julia> hasmethod((::Integer)->nothing, Tuple{Union{}})
true

Related discourse discussion here.

@stevengj stevengj added the types and dispatch Types, subtyping and method dispatch label Jan 23, 2019
@JeffBezanson
Copy link
Member

I think this is because these code paths never need to handle Union{} because it can't be the type of an object. These things tend to be highly optimized. I guess it would be nice to fix if possible though.

@tk3369
Copy link
Contributor

tk3369 commented Nov 24, 2021

Looks like this issue has been fixed. I've tested on both 1.6.4 and 1.7.0-rc3.

julia> hasmethod((::Int)->nothing, Tuple{Union{}})
true

julia> hasmethod((::Integer)->nothing, Tuple{Union{}})
true

tk3369 added a commit to tk3369/BinaryTraits.jl that referenced this issue Nov 24, 2021
The custom logic was originally developed to address a Bottom type issue with julialang (JuliaLang/julia#30808). However, the custom logic does not work properly for UnionAll signatures as seen from #54.

It appears that the original Julia hasmethod issue has been resolved. See my latest comment in that issue. So, I'm removing the custom logic here. All tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants