-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash#{update, merge!} ensure the receiver modifiable [Bug #17736] #4298
Hash#{update, merge!} ensure the receiver modifiable [Bug #17736] #4298
Conversation
@@ -1039,6 +1039,7 @@ ar_update(VALUE hash, st_data_t key, | |||
} | |||
old_key = key; | |||
retval = (*func)(&key, &value, arg, existing); | |||
rb_hash_modify(hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ar_update
is used only for small hashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮 Oh... I don't know it. Thank you for letting me know! 🙏
@@ -1631,7 +1632,7 @@ rb_hash_tbl(VALUE hash, const char *file, int line) | |||
return rb_hash_tbl_raw(hash, file, line); | |||
} | |||
|
|||
static void | |||
void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling in ar_update
makes compile error without this change, and
Lines 605 to 610 in db0ad48
void | |
rb_ary_modify(VALUE ary) | |
{ | |
rb_ary_modify_check(ary); | |
rb_ary_cancel_sharing(ary); | |
} |
Thank you for merging |
This PR aims a part of https://bugs.ruby-lang.org/issues/17736