Skip to content

Commit e24e50a

Browse files
rfourquetJeffBezanson
authored andcommitted
make union(::Tuple,...) work again (fix #25338) (#25354)
1 parent d481b1b commit e24e50a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ empty(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()
595595

596596
# like empty, but should return a mutable collection, a Vector by default
597597
emptymutable(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()
598+
emptymutable(itr, ::Type{U}) where {U} = Vector{U}()
598599

599600
## from general iterable to any array
600601

@@ -2043,4 +2044,4 @@ function hash(a::AbstractArray{T}, h::UInt) where T
20432044
end
20442045
!isequal(x2, x1) && (h = hash(x2, h))
20452046
return h
2046-
end
2047+
end

test/arrayops.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,15 @@ end
941941
@test isequal(symdiff([1,2,3], Float64[]), Float64[1.0,2,3])
942942
@test isequal(symdiff(Int64[], [1,2,3]), Int64[1,2,3])
943943
@test isequal(symdiff(Int64[]), Int64[])
944+
@testset "tuples" begin # Issue #25338
945+
@test union((1, 2), (3)) == [1, 2, 3]
946+
u = union((1, 0x2), [3])
947+
@test eltype(u) == Integer
948+
@test u == [1, 2, 3]
949+
@test intersect((1, 2), (3, 2)) == [2]
950+
@test setdiff((1, 2), (3, 2)) == [1]
951+
@test symdiff((1, 2), (3, 2)) == [1, 3]
952+
end
944953
end
945954

946955
@testset "mapslices" begin

0 commit comments

Comments
 (0)