From: Yusuke Endoh Date: 2012-02-13T20:49:11+09:00 Subject: [ruby-core:42532] [ruby-trunk - Bug #6008][Rejected] {a: 1}.hash not consistent over VM restarts Issue #6008 has been updated by Yusuke Endoh. Status changed from Feedback to Rejected When objects a and b are in different VM, a.eql?(b) does not make sense. If you pass the either object from one VM to the other in some way (such as using Marshal), a.eql?(b) will be satisfied, and then a.hash == b.hash will be also satisfied in the VM. Theory aside, the behavior (changing the value in each run) is intended for security reason. So we will not change the behavior. -- Yusuke Endoh ---------------------------------------- Bug #6008: {a: 1}.hash not consistent over VM restarts https://bugs.ruby-lang.org/issues/6008 Author: Jens Berlips Status: Rejected Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.0.0] $ ruby -e 'puts ({a: 1}.hash)' -2419336229553239378 $ ruby -e 'puts ({a: 1}.hash)' -4506930541181251952 $ ruby -e 'puts ({a: 1}.hash)' 2108665473238231010 $ ruby -e 'puts ({a: 1}.hash)' -3675793335936991568 But if you go to rvm 1.8.7 ruby -e 'puts ({:a => 1}.hash)' 425023 ruby -e 'puts ({:a => 1}.hash)' 425023 ruby -e 'puts ({:a => 1}.hash)' 425023 The documentation read: > Generates a Fixnum hash value for this object. This function must have the property that a.eql?(b) implies a.hash == b.hash. The hash value is used by class Hash. Any hash value that exceeds the capacity of a Fixnum will be truncated before > being used. Which implies that you should get the behaviour in 1.8.7. Regards, Jens -- http://bugs.ruby-lang.org/