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

Handling of <:Union{} #37255

Closed
bkamins opened this issue Aug 28, 2020 · 1 comment · Fixed by #37261
Closed

Handling of <:Union{} #37255

bkamins opened this issue Aug 28, 2020 · 1 comment · Fixed by #37261

Comments

@bkamins
Copy link
Member

bkamins commented Aug 28, 2020

I think this should not be allowed:

julia> f(::Type{Union{}}) = "a"
f (generic function with 1 method)

julia> f(::Type{<:Union{}}) = "b"
f (generic function with 2 methods)

julia> methods(f)
# 2 methods for generic function "f":
[1] f(::Type{var"#s1"} where var"#s1"<:Union{}) in Main at REPL[2]:1
[2] f(::Type{Union{}}) in Main at REPL[1]:1

julia> f(Union{})
"b"

and the compiler should identify that these two signatures are identical as Union{} is bottom type.

@bkamins bkamins changed the title Handling of <:Union{} type Handling of <:Union{} Aug 28, 2020
@martinholters
Copy link
Member

Indeed, given all of these:

julia> Type{Integer} == Type{T} where {Integer<:T<:Integer}
true

julia> Type{Int} == Type{T} where {Int<:T<:Int}
true

julia> Type{Any} == Type{T} where {Any<:T<:Any}
true

julia> Ref{Union{}} == Ref{T} where {Union{}<:T<:Union{}}
true

It's hard to justify that:

julia> Type{Union{}} == Type{T} where {Union{}<:T<:Union{}}
false

martinholters added a commit that referenced this issue Aug 28, 2020
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where 
{Union{}<:T<:Union{}})` false. Fixes #37255
JeffBezanson pushed a commit that referenced this issue Aug 29, 2020
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where 
{Union{}<:T<:Union{}})` false. Fixes #37255
JeffBezanson pushed a commit that referenced this issue Sep 8, 2020
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where
{Union{}<:T<:Union{}})` false. Fixes #37255

(cherry picked from commit 79a9ea0)
JeffBezanson pushed a commit that referenced this issue Sep 9, 2020
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where
{Union{}<:T<:Union{}})` false. Fixes #37255

(cherry picked from commit 79a9ea0)
KristofferC pushed a commit that referenced this issue Sep 10, 2020
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where
{Union{}<:T<:Union{}})` false. Fixes #37255

(cherry picked from commit 79a9ea0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants