Skip to content

Commit

Permalink
fix intersection with empty tuples (fix JuliaLang#25801) (JuliaLang#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet authored and JeffBezanson committed Mar 26, 2018
1 parent bf45de8 commit 89c4e3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ Maintain order with arrays.
"""
intersect!(s::AbstractSet, itrs...) = foldl(intersect!, s, itrs)
intersect!(s::AbstractSet, s2::AbstractSet) = filter!(_in(s2), s)
intersect!(s::AbstractSet, itr) = intersect!(s, union!(emptymutable(s), itr))
intersect!(s::AbstractSet, itr) =
intersect!(s, union!(emptymutable(s, eltype(itr)), itr))

"""
setdiff(s, itrs...)
Expand Down
7 changes: 7 additions & 0 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ end
# intersect must uniquify
@test intersect([1, 2, 1]) == intersect!([1, 2, 1]) == [1, 2]
@test intersect([1, 2, 1], [2, 2]) == intersect!([1, 2, 1], [2, 2]) == [2]

# issue #25801
x = () (:something,)
y = () (42,)
@test isempty(x)
@test isempty(y)
@test eltype(x) == eltype(y) == Union{}
end

@testset "setdiff" begin
Expand Down

0 comments on commit 89c4e3d

Please sign in to comment.