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

Changes for upcoming default frozen strings #1662

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

kotp
Copy link
Member

@kotp kotp commented Apr 21, 2024

The changes remove the magic comment for frozen strings, but also makes
mutable strings were necessary to avoid unnecessary test failures for
students.

The changes remove the magic comment for frozen strings, but also makes
mutable strings were necessary to avoid unnecessary test failures for
students.
@kotp kotp added ready x:status/claimed Someone is working on this issue x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises) labels Apr 21, 2024
@kotp kotp self-assigned this Apr 21, 2024
@kotp kotp requested a review from a team April 21, 2024 23:59
@meatball133
Copy link
Member

Generally, I am for this but the direction of Ruby as it currently seems to be moving towards frozen string literals, as can be seen by the planned changes in 3.4: https://github.com/ruby/ruby/blob/master/NEWS.md, which states:

String literals in files without a frozen_string_literal comment now behave as if they were frozen. If they are mutated a deprecation warning is emitted. These warnings can be enabled with -W:deprecated or by setting Warning[:deprecated] = true. To disable this change, you can run Ruby with the --disable-frozen-string-literal command line argument. [Feature #20205]

@kotp
Copy link
Member Author

kotp commented Apr 22, 2024

Generally, I am for this but the direction of Ruby as it currently seems to be moving towards frozen string literals, as can be seen by the planned changes in 3.4: https://github.com/ruby/ruby/blob/master/NEWS.md, which states:

String literals in files without a frozen_string_literal comment now behave as if they were frozen. If they are mutated a deprecation warning is emitted. These warnings can be enabled with -W:deprecated or by setting Warning[:deprecated] = true. To disable this change, you can run Ruby with the --disable-frozen-string-literal command line argument. [Feature #20205]

Absolutely and that is why I made the changes.

This is moving toward the default frozen strings, and all of the warnings are no longer there when checking for areas where frozen strings from us will cause an exception.

This is why I have done the +''' where I have to signal those are not immutable strings, while still being string literals, as an example.

@kotp kotp merged commit 363e7d3 into main Apr 22, 2024
5 checks passed
@kotp kotp deleted the upcoming_frozen_string_error_prevention branch April 22, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready x:status/claimed Someone is working on this issue x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants