Bug #1871: Hash#compare_by_identity Does Not Persist Over #dup or #clone
http://redmine.ruby-lang.org/issues/show/1871

Author: Run Paint Run Run
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.2dev (2009-08-03 trunk 24372) [i686-linux]

The "ident"ness of a Hash doesn't persist over #dup or #clone which makes those methods destructive when they rehash. Given that normally hash == hash.dup, and that default procs are retained over these two operations, I assume this is a bug.

  h = {'foo' => 'bar'}
  h.compare_by_identity
  h['foo'] = 'glark'

  p h                       #=> {"foo"=>"bar", "foo"=>"glark"}
  p h.compare_by_identity?  #=> true
  
  j = h.dup
  p j                       #=> {"foo"=>"glark"}
  p j.compare_by_identity?  #=> false


  k = h.clone
  p k                       #=> {"foo"=>"glark"}
  p k.compare_by_identity?  #=> false


----------------------------------------
http://redmine.ruby-lang.org