crystal
crystal copied to clipboard
`Hash#rehash` should remove duplicate elements
If a hash uses mutable keys and #compare_by_identity is not called, the keys might eventually compare equal due to external modifications. In this case Hash#rehash removes duplicate keys in Ruby:
a = [1]
b = [2]
c = {a => 3, b => 4}
a[0] = 2
c.rehash
c # => {[2] => 4}
The same code produces {[2] => 3, [2] => 4} in Crystal even after the #rehash call.