summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 40866509d1..285a13494a 100644
--- a/hash.c
+++ b/hash.c
@@ -1972,9 +1972,12 @@ static VALUE
rb_hash_s_ruby2_keywords_hash(VALUE dummy, VALUE hash)
{
Check_Type(hash, T_HASH);
- hash = rb_hash_dup(hash);
- RHASH(hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
- return hash;
+ VALUE tmp = rb_hash_dup(hash);
+ if (RHASH_EMPTY_P(hash) && rb_hash_compare_by_id_p(hash)) {
+ rb_hash_compare_by_id(tmp);
+ }
+ RHASH(tmp)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
+ return tmp;
}
struct rehash_arg {