diff options
author | Jeremy Evans <[email protected]> | 2022-11-09 09:37:04 -0800 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2023-03-24 10:55:13 -0700 |
commit | 1b13db25d8ed0f328acc4e86668f8ad7deae7221 (patch) | |
tree | f642a812e98c7c749bacb3be101205e179194bfc /hash.c | |
parent | d3197def882b47e7c57cdddfe8d62f62fef9d3f7 (diff) |
Copy compare_by_identity flag for empty hashes in Hash.ruby2_keywords_hash
This was already copied for non-empty hashes. As Hash.ruby2_keywords_hash
copies default values, it should also copy the compare_by_identity flag.
Partially Fixes [Bug #19113]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6702
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 { |