Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-02-13T16:38:24ZRuby Issue Tracking System
Redmine Ruby master - Bug #6008 (Rejected): {a: 1}.hash not consistent over VM restartshttps://bugs.ruby-lang.org/issues/60082012-02-13T16:38:24Zjensb (Jens Berlips)jens@berlips.com
<p>$ ruby -e 'puts ({a: 1}.hash)'<br>
-2419336229553239378<br>
$ ruby -e 'puts ({a: 1}.hash)'<br>
-4506930541181251952<br>
$ ruby -e 'puts ({a: 1}.hash)'<br>
2108665473238231010<br>
$ ruby -e 'puts ({a: 1}.hash)'<br>
-3675793335936991568</p>
<p>But if you go to rvm 1.8.7</p>
<p>ruby -e 'puts ({:a => 1}.hash)'<br>
425023<br>
ruby -e 'puts ({:a => 1}.hash)'<br>
425023<br>
ruby -e 'puts ({:a => 1}.hash)'<br>
425023</p>
<p>The documentation read:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>Which implies that you should get the behaviour in 1.8.7.</p>
<p>Regards,<br>
Jens</p>