[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>

Currently, ruby/spec is maintained mostly by individuals and enjoys the

13 messages 2016/12/13

[ruby-core:78816] [Ruby trunk Bug#12970] == Equality of recursive sets fails

From: p.szmielew@...
Date: 2016-12-23 21:54:13 UTC
List: ruby-core #78816
Issue #12970 has been updated by Piotr Szmielew.

File fix_recursive_sets.patch added

I've created patch for this issue.

Basically we need to rehash hash beneath set if (and only if) added object is self (therefore creating recursive set).

This patch add such rehash behaviour. This will also fix subset and superset behaviour to be coherent with set theory approach (recursive set is both self subset and superset).

In attachment you will find this patch for current ruby trunk.

----------------------------------------
Bug #12970: == Equality of recursive sets fails
https://bugs.ruby-lang.org/issues/12970#change-62220

* Author: Kevin de Berk
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.2.5, 2.3.3
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Comparing recursive arrays and hashes with equal? contents (save for the recursive element) using == succeeds.
However, using == to compare two recursive sets with equal? contents fails. I expect that to succeed.

See the attached script. This is my output for 2.2.5 and 2.3.3:

~~~
[1, 2, 3] == [1, 2, 3]? -> true
[1, 2, 3, [...]] == [1, 2, 3, [...]]? -> true
{:a=>1, :b=>2} == {:a=>1, :b=>2}? -> true
{:a=>1, :b=>2, :c=>{...}} == {:a=>1, :b=>2, :c=>{...}}? -> true
#<Set:0x00000001f90fc8> == #<Set:0x00000001f90500>? -> true
#<Set:0x00000001f92968> == #<Set:0x00000001f91478>? -> false
~~~


---Files--------------------------------
recursive_set_comparison.rb (871 Bytes)
fix_recursive_sets.patch (2.39 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next