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

subtyping bug: diagonality is ignored in union #26716

Closed
julbinb opened this issue Apr 5, 2018 · 0 comments · Fixed by #34272
Closed

subtyping bug: diagonality is ignored in union #26716

julbinb opened this issue Apr 5, 2018 · 0 comments · Fixed by #34272
Assignees
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@julbinb
Copy link

julbinb commented Apr 5, 2018

Both julia 0.6.2 and dev incorrectly say true on these judgments (on the left we have equivalent types, on the right the same type):

julia> (Tuple{Q,Bool} where Q<:Union{Int,P} where P) <: Tuple{Union{T,Int}, T} where T
true

julia> (Tuple{Union{Int,P},Bool} where P) <: Tuple{Union{T,Int}, T} where T
true

julia> (Union{Tuple{Int,Bool}, Tuple{P,Bool}} where P) <: Tuple{Union{T,Int}, T} where T
true

Correct answer is false, because variable T is (1) diagonal (2) matched both with P and Bool.

If we rewrite the RHS into an equivalent type with an explicit diagonal type, then julia gives a correct answer.

julia> (Tuple{Union{T,Int}, T} where T) == Union{Tuple{Int, T} where T, Tuple{T1,T1} where T1}
true

julia> (Tuple{Q,Bool} where Q<:Union{Int,P} where P) <: Union{Tuple{Int, T} where T, Tuple{T1,T1} where T1} 
false

julia> (Union{Tuple{Int,Bool}, Tuple{P,Bool}} where P) <: Union{Tuple{Int, T} where T, Tuple{T1,T1} where T1}
false
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

Successfully merging a pull request may close this issue.

2 participants