summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index e66ab126e9d..a8251dac7f9 100644
--- a/hash.c
+++ b/hash.c
@@ -268,8 +268,13 @@ static VALUE
rb_hash_dup(hash)
VALUE hash;
{
+ VALUE klass = CLASS_OF(hash);
+
NEWOBJ(dup, struct RHash);
- OBJSETUP(dup, CLASS_OF(hash), T_HASH);
+ while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = (VALUE)RCLASS(klass)->super;
+ }
+ OBJSETUP(dup, klass, T_HASH);
dup->iter_lev = 0;
dup->ifnone = RHASH(hash)->ifnone;