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

revert promotions of abstract arrays inside other arrays #47893

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1277,11 +1277,6 @@ el_same(::Type{T}, a::Type{<:AbstractArray{T,n}}, b::Type{<:AbstractArray{S,n}})
el_same(::Type{T}, a::Type{<:AbstractArray{S,n}}, b::Type{<:AbstractArray{T,n}}) where {T,S,n} = b
el_same(::Type, a, b) = promote_typejoin(a, b)

promote_result(::Type{<:AbstractArray}, ::Type{<:AbstractArray}, ::Type{T}, ::Type{S}) where {T,S} = (@inline; promote_type(T,S))
promote_result(::Type{T}, ::Type{S}, ::Type{Bottom}, ::Type{Bottom}) where {T<:AbstractArray,S<:AbstractArray} = (@inline; promote_typejoin(T,S))
# If no promote_rule is defined, both directions give Bottom. In that case use typejoin on the eltypes instead and give Array as the container.
promote_result(::Type{<:AbstractArray{T,n}}, ::Type{<:AbstractArray{S,n}}, ::Type{Bottom}, ::Type{Bottom}) where {T,S,n} = (@inline; Array{promote_type(T,S),n})

promote_rule(a::Type{UnitRange{T1}}, b::Type{UnitRange{T2}}) where {T1,T2} =
el_same(promote_type(T1, T2), a, b)
UnitRange{T}(r::UnitRange{T}) where {T<:Real} = r
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ julia> transpose(v) * v # compute the dot product

For a matrix of matrices, the individual blocks are recursively operated on:
```jldoctest
julia> C = reshape(1:4, 2, 2)
2×2 reshape(::UnitRange{Int64}, 2, 2) with eltype Int64:
julia> C = [1 3; 2 4]
2×2 Matrix{Int64}:
1 3
2 4

Expand Down
4 changes: 2 additions & 2 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ end
timesofar("conversions")

@testset "Promotions for size $sz" for (sz, T) in allsizes
@test isequal(promote(falses(sz...), zeros(sz...)),
@test_broken isequal(promote(falses(sz...), zeros(sz...)),
(zeros(sz...), zeros(sz...)))
@test isequal(promote(trues(sz...), ones(sz...)),
@test_broken isequal(promote(trues(sz...), ones(sz...)),
(ones(sz...), ones(sz...)))
ae = falses(1, sz...)
ex = (@test_throws ErrorException promote(ae, ones(sz...))).value
Expand Down
8 changes: 4 additions & 4 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,11 @@ end
@test_throws Base.CanonicalIndexError A[2] .= 0
@test_throws MethodError A[3] .= 0
A = [[1, 2, 3], 4:5]
@test A isa Vector{Vector{Int}}
A[1] .= 0
A[2] .= 0
@test A[1] == [0, 0, 0]
@test A[2] == [0, 0]
@test A[1] isa Vector{Int}
@test A[2] isa UnitRange
@test A[1] == [0,0,0]
@test_throws Base.CanonicalIndexError A[2] .= 0
end

# Issue #22180
Expand Down