Project

General

Profile

Actions

Bug #18470

closed

Union of two identical sets produces a set with duplicate members

Added by smokinggun (John Weir) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
[ruby-core:107028]

Description

We came across an issue where the union of two identical sets produced a non uniq Set.

We noticed this when upgrading from 2.7.1 to 3.1

See the attached test, the last assertion fails

C = Struct.new :id
a = Set.new
b = Set.new
f = C.new
a << f
f.id = 1
b << f
a + b
# => #<Set: {#<struct C id=1>, #<struct C id=1>}>
b + a
# => #<Set: {#<struct C id=1>}>

(a + b).uniq
=> [#<struct C id=1>]

Files

set_test.rb (348 Bytes) set_test.rb smokinggun (John Weir), 01/10/2022 08:22 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0