Open TotalVerb opened 7 years ago
julia> (Tuple{T,T} where T <: X) <: (Tuple{X{T},X{T}} where T)
false # expected true
this is correct. Tuple{Union{}, Union{}}
is a subtype of the left, but not of the right
julia> typeintersect(A, B) == A
true # shouldn't this imply A <: B?
no, typeintersect
can choose to return any type that is wider than the actual intersection. A valid answer thus is always A
(even if there is no actual intersection).
I am reopening this issue because seems that Tuple{Union{}, Union{}}
does not invalidate the subtype relationship
julia> (Tuple{Union{},Union{}}) <: (Tuple{X{T},X{T}} where T)
true
julia> (Tuple{Union{},Union{}}) <: (Tuple{T,T} where T <: X)
true
Yes, I think we could eventually make <:
return true in those cases. @vtjnash is right about typeintersect though.
Tuple{Union{}, Union{}} is a subtype of the left, but not of the right
So... we're not going to end up with method ambiguity errors when one doesn't deal with the (im)possibility of slots being Union{}
across different methods, are we?
Union{}
is going to cause a whole lot of ambiguity errors. Most of the time it doesn't matter though, because you rarely ever have those as a type parameter (any you can't construct an actual instance of it). We'll need a version of detect_ambiguities that ignores these though (I have one in some PR somewhere).
https://github.com/JuliaLang/julia/pull/20006 which needs rebasing to just be the last couple commits - we should probably change the default there, since the test that used to be verifying base was ambiguity-free is (hopefully temporarily) disabled
@andyferris No; type intersection treats Tuple{..., Union{}, ...}
the same as Union{}
.
OK, thanks for the clarification (phew!)
Tuple{Union{}} can no longer be constructed, so can we close this?
Given
Given
(the following observation was incorrect)