[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70273] [Ruby trunk - Bug #11422] All common set operations produce incorrect (and surprising) results on a set of sets

From: peter.hillerstrom@...
Date: 2015-08-08 16:08:28 UTC
List: ruby-core #70273
Issue #11422 has been updated by Peter Hillerström.


Mon_Ouie [pointed out](https://gist.github.com/Mon-Ouie/5efdab278cbabc3922ac) at freenode #Ruby irc channel, that I have different number of levels that I compare.

This works:
```ruby
pry(main):9> abc > Set.new([c])                                                                                        
=> true
pry(main):10> abc - Set.new([c])                                                                                       
=> #<Set: {#<Set: {"a", "b"}>}>
```

----------------------------------------
Bug #11422: All common set operations produce incorrect (and surprising) results on a set of sets
https://bugs.ruby-lang.org/issues/11422#change-53697

* Author: Peter Hillerström
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
# Set operations on a set of sets produce incorrect results

It seems that almost all common set operations (subtract, superset?, subset?, difference, etc...)
produce (mathematically) incorrect results on a set of sets, in that they just return the set of sets unmodified.

The union, intersection, and exclusion operations produce even weirder results, even when
both parameters are sets of sets – some members of the result are scalar values and some are sets.

```ruby
2.2.2 :119 > ab = Set.new(['A', 'B'])
 => #<Set: {"A", "B"}>
2.2.2 :120 > c = Set.new(['C'])
 => #<Set: {"C"}>
2.2.2 :121 > abc = Set.new([ab, c])
```

## Substraction fails
```ruby
2.2.2 :122 > abc - c
 => #<Set: {#<Set: {"A", "B"}>, #<Set: {"C"}>}>
```

## Superset fails
```ruby
2.2.2 :140 > abc > ab
=> false
```

See [more examples](http://pastie.org/10337538#18) on pastie.org.
Python just throws `TypeError: unhashable type: 'set'`.



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

In This Thread

Prev Next