Project

General

Profile

Bug #118

SortedSet#inspect does not work with nested SortedSets

Added by NoKarma (Arthur Schreiber) almost 12 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
[ruby-core:17146]

Description

=begin
SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed
=end


Files

set.patch (2.17 KB) set.patch NoKarma (Arthur Schreiber), 06/10/2008 05:43 PM
set.patch (2.58 KB) set.patch NoKarma (Arthur Schreiber), 06/10/2008 09:56 PM
#1

Updated by knu (Akinori MUSHA) almost 12 years ago

=begin
SortedSet cannot be put in a SortedSet because it is not comparable (unsortable).

How do you define comparison between two (sorted) sets?
=end

#2

Updated by Anonymous almost 12 years ago

=begin
Issue #118 has been updated by Akinori MUSHA.

SortedSet cannot be put in a SortedSet because it is not comparable (unsortable).

How do you define comparison between two (sorted) sets?


Bug #118: SortedSet#inspect does not work with nested SortedSets
http://redmine.ruby-lang.org/issues/show/118

Author: Arthur Schreiber
Status: Open
Priority: Normal
Assigned to: Akinori MUSHA
Category:
Target version:

SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

=end

#3

Updated by NoKarma (Arthur Schreiber) almost 12 years ago

=begin
Here is a patch that makes SortedSet#add check that any object added to a SortedSet includes the Comparable module.
It also extends the SortedSet documentation to make it more clear how SortedSet works.
=end

#4

Updated by Anonymous almost 12 years ago

=begin
Issue #118 has been updated by Arthur Schreiber.

File set.patch added

Here is a patch that makes SortedSet#add check that any object added to a SortedSet includes the Comparable module.
It also extends the SortedSet documentation to make it more clear how SortedSet works.


Bug #118: SortedSet#inspect does not work with nested SortedSets
http://redmine.ruby-lang.org/issues/show/118

Author: Arthur Schreiber
Status: Open
Priority: Normal
Assigned to: Akinori MUSHA
Category:
Target version:

SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

=end

#5

Updated by knu (Akinori MUSHA) almost 12 years ago

=begin
add() is not the only method that adds new elements to a set, but merge() also is.

For merge(), you can omit the check when the given enumerable object is a SortedSet.
=end

#6

Updated by Anonymous almost 12 years ago

=begin
Issue #118 has been updated by Akinori MUSHA.

add() is not the only method that adds new elements to a set, but merge() also is.

For merge(), you can omit the check when the given enumerable object is a SortedSet.


Bug #118: SortedSet#inspect does not work with nested SortedSets
http://redmine.ruby-lang.org/issues/show/118

Author: Arthur Schreiber
Status: Open
Priority: Normal
Assigned to: Akinori MUSHA
Category:
Target version:

SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

=end

#7

Updated by NoKarma (Arthur Schreiber) almost 12 years ago

=begin
SortedSet#merge calls super (Set#merge), which in turn calls SortedSet#add for non-Set objects.
So the only check needed is on SortedSet#add.
=end

#8

Updated by Anonymous almost 12 years ago

=begin
Issue #118 has been updated by Arthur Schreiber.

SortedSet#merge calls super (Set#merge), which in turn calls SortedSet#add for non-Set objects. So the only check needed is on SortedSet#add.


Bug #118: SortedSet#inspect does not work with nested SortedSets
http://redmine.ruby-lang.org/issues/show/118

Author: Arthur Schreiber
Status: Open
Priority: Normal
Assigned to: Akinori MUSHA
Category:
Target version:

SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

=end

#9

Updated by NoKarma (Arthur Schreiber) almost 12 years ago

=begin
I attached a new patch for the set library.

I changed Set#merge to only directly use the passed objects @hash instance variable when self
and the passed object are instances of the same class.

This prevents the addition of non-Comparable Objects when calling SortedSet#merge with a Set.

I hope the patch is ok now.
=end

#10

Updated by Anonymous almost 12 years ago

=begin
Issue #118 has been updated by Arthur Schreiber.

File set.patch added

I attached a new patch for the set library.

I changed Set#merge to only directly use the passed objects @hash instance variable, when self
and the passed object are instances of the same class.

This prevents bugs when using a SortedSet in conjunction with the rbtree library.
Additionally, It prevents the merging of non-Comparable Objects when calling SortedSet#merge with a Set.

I hope the patch is ok now.


Bug #118: SortedSet#inspect does not work with nested SortedSets
http://redmine.ruby-lang.org/issues/show/118

Author: Arthur Schreiber
Status: Open
Priority: Normal
Assigned to: Akinori MUSHA
Category:
Target version:

SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

=end

#11

Updated by knu (Akinori MUSHA) almost 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23322.
=end

Also available in: Atom PDF