Bug #9231
closedThe value of [].hash is equal to the value of false.hash
Description
I found that [].hash == false.hash.
And the combinations of each elements also have the same value.
Is this an intended behavior?
C:\Users\phasis>irb
irb(main):001:0> [].hash
=> 1336528015
irb(main):002:0> false.hash
=> 1336528015
irb(main):003:0> [false,false].hash
=> -1570892633
irb(main):004:0> [false,[]].hash
=> -1570892633
irb(main):005:0> [[],false].hash
=> -1570892633
irb(main):006:0> [[],[]].hash
=> -1570892633
irb(main):008:0> {false=>false}.hash
=> -539662806
irb(main):009:0> {[]=>[]}.hash
=> -539662806
irb(main):010:0> {[]=>false}.hash
=> -539662806
irb(main):011:0> {false=>[]}.hash
=> -539662806
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44125.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
array.c, hash.c: add salt
- array.c (rb_ary_hash): add salt to differentiate false and empty
array. [ruby-core:58993] [Bug #9231] - hash.c (rb_any_hash, rb_hash_hash): ditto.