Skip to content

Commit d5e0091

Browse files
author
KristofferC
committed
revert promotions of abstract arrays inside other arrays
1 parent 0fbe56e commit d5e0091

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

base/range.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,11 +1277,6 @@ el_same(::Type{T}, a::Type{<:AbstractArray{T,n}}, b::Type{<:AbstractArray{S,n}})
12771277
el_same(::Type{T}, a::Type{<:AbstractArray{S,n}}, b::Type{<:AbstractArray{T,n}}) where {T,S,n} = b
12781278
el_same(::Type, a, b) = promote_typejoin(a, b)
12791279

1280-
promote_result(::Type{<:AbstractArray}, ::Type{<:AbstractArray}, ::Type{T}, ::Type{S}) where {T,S} = (@inline; promote_type(T,S))
1281-
promote_result(::Type{T}, ::Type{S}, ::Type{Bottom}, ::Type{Bottom}) where {T<:AbstractArray,S<:AbstractArray} = (@inline; promote_typejoin(T,S))
1282-
# 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.
1283-
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})
1284-
12851280
promote_rule(a::Type{UnitRange{T1}}, b::Type{UnitRange{T2}}) where {T1,T2} =
12861281
el_same(promote_type(T1, T2), a, b)
12871282
UnitRange{T}(r::UnitRange{T}) where {T<:Real} = r

test/bitarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ end
9898
timesofar("conversions")
9999

100100
@testset "Promotions for size $sz" for (sz, T) in allsizes
101-
@test isequal(promote(falses(sz...), zeros(sz...)),
101+
@test_broken isequal(promote(falses(sz...), zeros(sz...)),
102102
(zeros(sz...), zeros(sz...)))
103-
@test isequal(promote(trues(sz...), ones(sz...)),
103+
@test_broken isequal(promote(trues(sz...), ones(sz...)),
104104
(ones(sz...), ones(sz...)))
105105
ae = falses(1, sz...)
106106
ex = (@test_throws ErrorException promote(ae, ones(sz...))).value

test/broadcast.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,11 @@ end
699699
@test_throws Base.CanonicalIndexError A[2] .= 0
700700
@test_throws MethodError A[3] .= 0
701701
A = [[1, 2, 3], 4:5]
702-
@test A isa Vector{Vector{Int}}
703702
A[1] .= 0
704-
A[2] .= 0
705-
@test A[1] == [0, 0, 0]
706-
@test A[2] == [0, 0]
703+
@test A[1] isa Vector{Int}
704+
@test A[2] isa UnitRange
705+
@test A[1] == [0,0,0]
706+
@test_throws Base.CanonicalIndexError A[2] .= 0
707707
end
708708

709709
# Issue #22180

0 commit comments

Comments
 (0)