Skip to content

Commit

Permalink
fixes IntSet copy!(a,a) for a === a; #14581
Browse files Browse the repository at this point in the history
(cherry picked from commit 166f484)
ref #14582
  • Loading branch information
Zachary Sunberg authored and tkelman committed Jan 9, 2016
1 parent 4cd00d1 commit 93ccda0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions base/intset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ function symdiff!(s::IntSet, ns)
end

function copy!(to::IntSet, from::IntSet)
empty!(to)
union!(to, from)
if is(to, from)
return to
else
empty!(to)
return union!(to, from)
end
end

function in(n::Integer, s::IntSet)
Expand Down
2 changes: 2 additions & 0 deletions test/intset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ k = IntSet([4, 5])
copy!(k, i)
@test k == i
@test !(k === i)
copy!(k, k)
@test k == i

# unions
i = IntSet([1, 2, 3])
Expand Down

0 comments on commit 93ccda0

Please sign in to comment.