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

known subtyping issue #40407

Open
vtjnash opened this issue Apr 8, 2021 · 2 comments
Open

known subtyping issue #40407

vtjnash opened this issue Apr 8, 2021 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@vtjnash
Copy link
Member

vtjnash commented Apr 8, 2021

julia> let a = Tuple{T3,Int64,Tuple{T3}} where T3,
           b = Tuple{S3,S3,S4} where S4 where S3,
           x = Tuple{Int64,Int64,Tuple{Int64}}
           typeintersect(a, b) <: a
       end
false # subtype is wrong about (Tuple{S3,S3,S4} where S4<:Tuple{Int64} where S3<:Int64) -- possibly a normalization issue?

julia> let a = Tuple{T1,Val{T2},T2} where T2 where T1,
           b = Tuple{Float64,S1,S2} where S2 where S1,
           x = Tuple{Float64,Val{Int64},Int64}
           typeintersect(a, b) <: a
       end
false # suboptimal, but valid (type-intersection was over-approximated)

from #19998

@vtjnash vtjnash added the types and dispatch Types, subtyping and method dispatch label Apr 8, 2021
@nsajko
Copy link
Contributor

nsajko commented Aug 12, 2024

The first example now returns true.

@vtjnash
Copy link
Member Author

vtjnash commented Aug 12, 2024

The second example also has the wrong value for x, it should be x = Tuple{Float64,Val{T2},T2} where T2 <: Int. The first example, similarly, may be only correct now because we disallow Union{} being an element. Otherwise this precise intersection gets harder to express, as it should be Tuple{S3, Int64, S4} where {S3<:Int64, S4<:Tuple{S3}}, which excludes Tuple{Union{}, Int64, Tuple{Int64}} from the set of valid intersections in the return value.

In v1.10, before we fixed that, this example violated transitivity:

julia> x <: a
true

julia> x <: b
true

julia> y <: a
true

julia> y <: b
false

julia> y <: x
true

julia> x <: y
true

julia> y <: x
true

@vtjnash vtjnash closed this as completed Aug 12, 2024
@vtjnash vtjnash reopened this Aug 12, 2024
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

2 participants