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

Open
julbinb opened this Issue Apr 5, 2018 · 0 comments

Comments

2 participants
@julbinb

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