Bug #4104

String#hash should return different value for different string.

Added by Heesob Park over 4 years ago. Updated almost 4 years ago.

[ruby-core:33500]
Status:Closed
Priority:Normal
Assignee:-
ruby -v: Backport:

Description

=begin
On Ruby 1.9.x, String#hash returns same value for any "\x00" trailing string.

C:\work>irb
irb(main):001:0> "a".hash
=> -242103097
irb(main):002:0> "a\x00".hash
=> -242103097
irb(main):003:0> "a\x00\x00".hash
=> -242103097

On Ruby 1.8.6, String#hash returns different value for different string.

C:\work>irb
irb(main):001:0> "a".hash
=> 100
irb(main):002:0> "a\x00".hash
=> 6561949
irb(main):003:0> "a\x00\x00".hash
=> 826408672

I think that String#hash should return different value for different string.
=end

History

#1 Updated by Nobuyoshi Nakada over 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r29991.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF