This project is archived and is in readonly mode.

#5724 ✓resolved
Steve Richert

Subclasses of HashWithIndifferentAccess dup the wrong class

Reported by Steve Richert | September 28th, 2010 @ 03:56 PM

There are two instances of HashWithIndifferentAccess being named explicitly in its own class. No bug there, but if a new class is created that inherits from HashWithIndifferentAccess, the new_from_hash_copying_default class method and the dup instance method incorrectly return an instance of HashWithIndifferentAccess rather than the newly-created class.

class FooHash < HashWithIndifferentAccess
end

foo = FooHash.new # => {}
foo.class         # => FooHash
bar = foo.dup     # => {}
bar.class         # => HashWithIndifferentAccess

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages