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

suboptimal type-intersections #36951

Closed
vtjnash opened this issue Aug 6, 2020 · 5 comments
Closed

suboptimal type-intersections #36951

vtjnash opened this issue Aug 6, 2020 · 5 comments
Assignees
Labels
feature Indicates new feature / enhancement requests types and dispatch Types, subtyping and method dispatch

Comments

@vtjnash
Copy link
Member

vtjnash commented Aug 6, 2020

julia> typeintersect(Type{T} where T>:Missing, Type{Some{T}} where T)
Type{Some{T}} where T

julia> typeintersect(Type{Union{Missing,T}} where T, Type{Some{T}} where T)
Union{}

julia> (Type{T} where {T>:Missing}) == Type{Union{Missing,T}} where T
true
julia> typeintersect(Tuple{typeof(convert),Type{T},T} where T, Tuple{typeof(convert),Type{T},Any} where T>:Nothing)
Tuple{typeof(convert),Type{T},Any} where T>:Nothing
# preferred: Tuple{typeof(convert),Type{T},T} where T>:Nothing
@vtjnash vtjnash added the types and dispatch Types, subtyping and method dispatch label Aug 6, 2020
@vtjnash
Copy link
Member Author

vtjnash commented Aug 6, 2020

Another similar one:

julia> typeintersect(
  Tuple{typeof(vcat),Vararg{Union{Vector{T}, Matrix{T}, LinearAlgebra.Adjoint{T,Vector{T}}, LinearAlgebra.Transpose{T,Vector{T}}, LinearAlgebra.AbstractTriangular{T,A} where A<:(Matrix{T} where T), LinearAlgebra.Hermitian{T,A} where A<:(Matrix{T} where T), LinearAlgebra.Symmetric{T,A} where A<:(Matrix{T} where T)},N} where N} where T,
  Tuple{typeof(vcat),Vararg{Number,N} where N})
Tuple{typeof(vcat),Vararg{Number,N} where N} # returned LHS
# preferred: Tuple{typeof(vcat),Vararg{Union{}}}

@vtjnash
Copy link
Member Author

vtjnash commented Aug 6, 2020

Another similar one:

julia> typeintersect(
  Tuple{typeof(LinearAlgebra.ldiv!),LinearAlgebra.Adjoint{var"#s812",var"#s811"} where var"#s811"<:(LinearAlgebra.LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64},
  Tuple{typeof(LinearAlgebra.ldiv!),LinearAlgebra.Adjoint{var"#s812",var"#s811"} where var"#s811"<:(LinearAlgebra.UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64})
Tuple{typeof(ldiv!),Adjoint{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64} # returned LHS
# preferred: Tuple{typeof(ldiv!),Adjoint{var"#s812",Union{}} where var"#s812",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}

@vtjnash
Copy link
Member Author

vtjnash commented Aug 7, 2020

Essentially the same:

julia> typeintersect(
  Tuple{LinearAlgebra.var"#eigvals!##kw",Any,typeof(LinearAlgebra.eigvals!),StridedMatrix{T},StridedMatrix{T}} where T<:Union{Float32, Float64},
  Tuple{LinearAlgebra.var"#eigvals!##kw",Any,typeof(LinearAlgebra.eigvals!),StridedMatrix{T},StridedMatrix{T}} where T<:Union{ComplexF32, ComplexF64})
Tuple{LinearAlgebra.var"#eigvals!##kw",Any,typeof(eigvals!),StridedMatrix{T},StridedMatrix{T}} where T<:Union{ComplexF32, ComplexF64}
# preferred: Tuple{LinearAlgebra.var"#eigvals!##kw",Any,typeof(eigvals!),StridedMatrix{Union{}},StridedMatrix{Union{}}}

vtjnash added a commit that referenced this issue Sep 2, 2020
With the improved internal implementation of ambiguity testing, it's useful now to lean on that existing support more heavily and compute a lighter version here, fixing some issues with the previous one. Most of these new failures are likely to be type-intersection issues (#36951), which previously were excluded from analysis entirely.
@JeffBezanson JeffBezanson self-assigned this Sep 22, 2020
@vtjnash vtjnash added the feature Indicates new feature / enhancement requests label Jan 26, 2024
@vtjnash vtjnash closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
@vtjnash
Copy link
Member Author

vtjnash commented Aug 16, 2024

suboptimal in many cases here, but not wrong, and the original ones are fixed

@oscardssmith
Copy link
Member

should we add these as tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

3 participants