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

OpenStruct: support for frozen string #1714

Closed
wants to merge 1 commit into from

Conversation

esparta
Copy link
Contributor

@esparta esparta commented Oct 11, 2017

OpenStruct need minimal changes to switch to # frozen_string_literal: true
The only method with mutable strings is inspect.

Bug #14000: https://bugs.ruby-lang.org/issues/14000

OpenStruct need minimal changes to switch to # frozen_string_literal: true
The only method with mutable strings is `inspect`.

Bug #14000: https://bugs.ruby-lang.org/issues/14000
@mikegee
Copy link

mikegee commented Oct 11, 2017

There was one "=" that will now be frozen with this change. This also introduces a ',' which will be frozen.

matzbot pushed a commit that referenced this pull request Oct 24, 2017
Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
@marcandre
Copy link
Member

Thanks for the PR!

It is now merged. I adapted it a bit to avoid returning a frozen string. I highly doubt there's anyone calling to_s or inspect on an OpenStruct and then mutating the result but better be safe than sorry. I think the resulting code is quite readable 😄

Let me know if I've missed anything.

@marcandre marcandre closed this Oct 24, 2017
mrkn pushed a commit to mrkn/ruby that referenced this pull request Dec 1, 2017
Patch adapted from Espartaco Palma. [rubyGH-1714] [Bug #14000]

git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
@esparta esparta deleted the openstruct_frozen_string branch February 14, 2018 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants