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

Don't freeze input strings #28729

Merged
merged 1 commit into from Apr 11, 2017

Conversation

Projects
None yet
4 participants
@matthewd
Member

matthewd commented Apr 11, 2017

See 34321e4 for background on ImmutableString vs String.

Our String type cannot delegate typecasting to ImmutableString, because the latter freezes its input: duplicating the value after that gives us an unfrozen result, but still mutates the originally passed object.

Fixes #24185
Fixes #28718

Don't freeze input strings
See 34321e4 for background on
ImmutableString vs String.

Our String type cannot delegate typecasting to ImmutableString, because
the latter freezes its input: duplicating the value after that gives us
an unfrozen result, but still mutates the originally passed object.
::String.new(super)
case value
when ::String then ::String.new(value)
when true then "t".freeze

This comment has been minimized.

@rafaelfranca

rafaelfranca Apr 11, 2017

Member

It just sucks that we have to duplicate the conditionals and the true and false cases.

@rafaelfranca

rafaelfranca Apr 11, 2017

Member

It just sucks that we have to duplicate the conditionals and the true and false cases.

This comment has been minimized.

@kaspth

kaspth Apr 11, 2017

Member

True, but it seems the rate of change on these branches is fairly low.

@kaspth

kaspth Apr 11, 2017

Member

True, but it seems the rate of change on these branches is fairly low.

@matthewd matthewd merged commit fff414e into rails:master Apr 11, 2017

2 checks passed

codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

matthewd added a commit that referenced this pull request Apr 11, 2017

matthewd added a commit that referenced this pull request Apr 11, 2017

@matthewd

This comment has been minimized.

Show comment
Hide comment
@matthewd
Member

matthewd commented Apr 11, 2017

@matthewd matthewd deleted the matthewd:dont-freeze-inputs branch Jun 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment