Skip to content

Handle non-string keys returning immediate values via to_s #792

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

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

byroot
Copy link
Member

@byroot byroot commented Apr 27, 2025

We can't directly call RBASIC_CLASS as the return value of to_s may be an immediate.

@byroot byroot force-pushed the handle-to-s-immediate branch from 365c4b9 to b2cd83f Compare April 27, 2025 09:58
We can't directly call `RBASIC_CLASS` as the return value of
`to_s` may be an immediate.
@byroot byroot force-pushed the handle-to-s-immediate branch from b2cd83f to 12dc394 Compare April 27, 2025 10:13
@byroot byroot merged commit 05cc998 into ruby:master Apr 27, 2025
33 checks passed
{
VALUE key_to_s = rb_funcall(key, i_to_s, 0);

if (RB_UNLIKELY(rb_type(key_to_s) != T_STRING)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it doesn't handle T_STRING explicitly currently, so I guess it's the same, but maybe in the future it might?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unlucky path, so I don't think it matter too much, but it's nicer to read, so I changed it.

@byroot byroot deleted the handle-to-s-immediate branch April 27, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants