Bug #118 [ruby-core:17146]
SortedSet#inspect does not work with nested SortedSets
| Status : | Open | Start : | 06/09/2008 | |
| Priority : | Normal | Due date : | ||
| Assigned to : | Akinori MUSHA | % Done : | 0% |
|
| Category : | - | |||
| Target version : | - | |||
Description
SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed
History
06/09/2008 06:10 PM - Akinori MUSHA
SortedSet cannot be put in a SortedSet because it is not comparable (unsortable). How do you define comparison between two (sorted) sets?
06/09/2008 06:11 PM - Anonymous
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
06/10/2008 05:43 PM - 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.
06/10/2008 05:58 PM - Anonymous
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
06/10/2008 06:17 PM - 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.
06/10/2008 06:24 PM - Anonymous
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
06/10/2008 06:50 PM - 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.
06/10/2008 06:58 PM - Anonymous
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
06/10/2008 09:56 PM - 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 the addition of non-Comparable Objects when calling SortedSet#merge with a Set. I hope the patch is ok now.
06/10/2008 10:04 PM - Anonymous
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