Skip to content
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

Fix String#encode's fallback option, it should accept an object which has [] method #213

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented Feb 24, 2020

Problem

String#encode accepts an object which has [] method as a fallback, but the type definition does not accept it.

Solution

Update the type of fallback option to accept it.
And I'd like to use the type for Pathname#binwrite because it accepts keyword arguments of String#encode. So I expose String::encode_fallback as a type alias.

Note

Note that actually an object with [] method does not work as a fallback in Ruby 2.7.0.
I reported the problem to bugs.ruby-lang.org, and it has been fixed.
https://bugs.ruby-lang.org/issues/16649

I concerned the stdlib test raises an error, but it works well. Because the fallback option is passed but it is not used.

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

👍

@soutaro soutaro merged commit f2e9073 into ruby:master Feb 25, 2020
@pocke pocke deleted the String#encode-fallback-aref branch February 25, 2020 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants