You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to allow my function to take two arguments. One is the usual of variable type T and the second one may be either of the same type T or it can be my custom container type Cont{T}. Unfortunately, it looks like in this case type checker decides to turn off the diagonal type checks. So here are refined examples:
julia> Tuple{Int64,Float64} <: Tuple{T,T} where T
false # normal
julia> Tuple{Int64,Float64} <: Tuple{T,Union{Array{T}, T}} where T
true # breaking
julia> Tuple{Int64,Array{Float64}} <: Tuple{T,Union{Array{T}, T}} where T
true # breaking
julia> Tuple{Int64,Array{Float64}} <: Tuple{T,Union{Array{T}, T}} where T <: Number
false # adding type constraint here helps for some reason
julia> Tuple{Int64,Float64} <: Tuple{T,Union{Array{T}, T}} where T<:Number
true # but here it doesn't
Reproduces both on 1.5.1 and on the master branch versions.
The text was updated successfully, but these errors were encountered:
This was an intentional change (#34272) needed to fix bugs. I agree it's inconvenient though. It might be possible to make this case work without totally reverting that change.
Intuitively, Tuple{T,Union{Cont{T}, T}} where T should be the same as Union{Tuple{T,T} where T, Tuple{Cont{T}, T} where T}. One could probably get away by defining two methods, f(::T, ::T) where T and f(::T, ::Cont{T}) where T, and calling the former from the latter to avoid code duplication. Of course, the latter method allows abstract T in the container whereas the former does not.
I want to allow my function to take two arguments. One is the usual of variable type T and the second one may be either of the same type T or it can be my custom container type Cont{T}. Unfortunately, it looks like in this case type checker decides to turn off the diagonal type checks. So here are refined examples:
Reproduces both on 1.5.1 and on the master branch versions.
The text was updated successfully, but these errors were encountered: