[ruby-dev:47842] Re: [ruby-cvs:51126] nobu:r43981 (trunk): hash.c: same hash value for similar constructs
From:
Tanaka Akira <akr@...>
Date:
2013-12-03 13:53:11 UTC
List:
ruby-dev #47842
2013/12/3 <[email protected]>: > nobu 2013-12-03 22:32:24 +0900 (Tue, 03 Dec 2013) > > New Revision: 43981 > > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43981 > > Log: > hash.c: same hash value for similar constructs > > * hash.c (rb_hash_recursive): make similar (recursive) constructs > return same hash value. execute recursively, and rewind to the > topmost frame with an object which .eql? to the recursive > object, if recursion is detected. eql? だけど hash が等しくない例を作って見ました。 % ./ruby -ve ' a1 = [] a2 = [] a3 = [{1=>a1, 2=>a2}] a4 = [[a3]] a1 << a3 a2 << a4 b1 = [] b2 = [] b3 = [{2=>b2, 1=>b1}] b4 = [[b3]] b1 << b3 b2 << b4 p a4.eql?(b4) p a4.hash == b4.hash ' ruby 2.1.0dev (2013-12-03 trunk 43981) [x86_64-linux] true false -- [田中 哲][たなか あきら][Tanaka Akira]