ruby-changes:11682
From: knu <ko1@a...>
Date: Fri, 1 May 2009 16:52:24 +0900 (JST)
Subject: [ruby-changes:11682] Ruby:r23321 (trunk): * lib/set.rb (Set#merge): Only directly use the passed objects
knu 2009-05-01 16:52:09 +0900 (Fri, 01 May 2009) New Revision: 23321 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23321 Log: * lib/set.rb (Set#merge): Only directly use the passed objects @hash instance variable when self and the passed object are instances of the same class. [Bug #118] Modified files: trunk/ChangeLog trunk/lib/set.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 23320) +++ ChangeLog (revision 23321) @@ -1,3 +1,9 @@ +Fri May 1 16:50:05 2009 Akinori MUSHA <knu@i...> + + * lib/set.rb (Set#merge): Only directly use the passed objects + @hash instance variable when self and the passed object are + instances of the same class. [Bug #118] + Fri May 1 16:44:11 2009 Akinori MUSHA <knu@i...> * lib/set.rb (SortedSet#add): Do not let an uncomparable object Index: lib/set.rb =================================================================== --- lib/set.rb (revision 23320) +++ lib/set.rb (revision 23321) @@ -276,8 +276,8 @@ # Merges the elements of the given enumerable object to the set and # returns self. def merge(enum) - if enum.is_a?(Set) - @hash.update(enum.instance_eval { @hash }) + if enum.instance_of?(self.class) + @hash.update(enum.instance_variable_get(:@hash)) else enum.each { |o| add(o) } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/