Skip to content

[Ruby 3.4] Add tests for warning about mutating chilled Strings and String#+@ - #1298

Merged
eregon merged 2 commits into
ruby:masterfrom
trinistr:3.4-mutating-string-literals
Jan 4, 2026
Merged

[Ruby 3.4] Add tests for warning about mutating chilled Strings and String#+@#1298
eregon merged 2 commits into
ruby:masterfrom
trinistr:3.4-mutating-string-literals

Conversation

@trinistr

@trinistr trinistr commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

From #1265.

String literals in files without a frozen_string_literal comment now emit a deprecation warning
when they are mutated.
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]

  • String#+@ now duplicates when mutating the string would emit
    a deprecation warning, offered as a replacement for the
    str.dup if str.frozen? pattern.

Maybe this needs to be squashed? But they are separate things 🤷

@trinistr
trinistr marked this pull request as ready for review November 11, 2025 21:36
@trinistr
trinistr force-pushed the 3.4-mutating-string-literals branch from af08d92 to 80c7135 Compare November 11, 2025 21:37
@eregon
eregon merged commit 537cf29 into ruby:master Jan 4, 2026
12 checks passed
@eregon

eregon commented Jan 4, 2026

Copy link
Copy Markdown
Member

Thank you, looks good, sorry for very late review

@trinistr

trinistr commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing so much stuff!

@trinistr
trinistr deleted the 3.4-mutating-string-literals branch January 5, 2026 21:02
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.

2 participants