I believe this might be considered a bug in type promotion, but I wanted to ask here first before reporting an issue. In Julia v1.2.0 and v1.3.0-rc4.1, I see the following behavior:
julia> promote_type(ComplexF64,Float32)
Complex{Float64}
julia> promote_type(Vector{ComplexF64},Vector{Float32})
Array{Complex{Float64},1}
as I would expect. However, I also see this:
julia> promote_type(ComplexF32,Float64)
Complex{Float64}
julia> promote_type(Vector{ComplexF32},Vector{Float64})
Array{T,1} where T
even though I would expect Array{Complex{Float64},1}
. This also seems to happen with other numeric types:
julia> promote_type(Complex{Int32},Int64)
Complex{Int64}
julia> promote_type(Vector{Complex{Int32}},Vector{Int64})
Array{T,1} where T
julia> promote_type(ComplexF16,Float64)
Complex{Float64}
julia> promote_type(Vector{ComplexF16},Vector{Float64})
Array{T,1} where T
It seems like the promotion rule should be:
promote_rule(::Type{Array{T,N}},::Type{Array{S,N}}) where {T,S,N} = Array{promote_type(T,S),N}
but that doesn’t seem to be the case here.
Any idea if this is expected behavior or just a missing promote_rule
?
-Matt