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

Ensure compatibility with --enable-frozen-string-literal #572

Closed
wants to merge 1 commit into from

Conversation

casperisfine
Copy link

Ref: https://bugs.ruby-lang.org/issues/20205

In Ruby 3.4 string literals will be "chilled" by default. Meaning they are still mutable, but will pretend to be frozen.

In most case it has no impact, just emit a few warnings there and there, but there is one thing it impacts is the StringIO.new('') pattern. StringIO checks if the given string is frozen, and if it is will act as a read only IO.

This breaks rubyzip 2.x.

This commit make the 2.x branch compatible with frozen string literals.

Note: I see all these issues are solved on master, but only released in an alpha, and I suppose ultimately will require a major version upgrade.

I think it would be good to provide a 2.x version compatible with Ruby 3.4, but your call.

Ref: https://bugs.ruby-lang.org/issues/20205

In Ruby 3.4 string literals will be "chilled" by default. Meaning
they are still mutable, but will pretend to be frozen.

In most case it has no impact, just emit a few warnings there and
there, but there is one thing it impacts is the `StringIO.new('')`
pattern. `StringIO` checks if the given string is frozen, and if
it is will act as a read only IO.

This breaks rubyzip 2.x.

This commit make the 2.x branch compatible with frozen string literals.
@hainesr
Copy link
Member

hainesr commented Apr 8, 2024

Thanks for doing this.

I have to say my initial thought though was that I'd like to leave the 2.x branch (and Ruby 2.x) behind and frozen string literals would be a good way of doing this. However, it occurs to me that 3.x declares frozen_string_literal: true in every file, so it's certainly worth having 2.4 support this so that people can test before moving to 3.0.

I'll merge this to the 2.4 branch, thanks.

@casperisfine
Copy link
Author

Thank you very much 🙇

@hainesr
Copy link
Member

hainesr commented Apr 8, 2024

Merged into the 2.4 branch now.

Thanks again for your help!

@hainesr hainesr closed this Apr 8, 2024
@hainesr
Copy link
Member

hainesr commented Apr 8, 2024

Released in 2.4.rc1 on rubygems now!

@miry
Copy link

miry commented Apr 11, 2024

It works, thank you very much.

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.

None yet

4 participants