Suppress "literal string will be frozen in the future" warning#1019
Merged
tompng merged 2 commits intoruby:masterfrom Oct 18, 2024
Merged
Suppress "literal string will be frozen in the future" warning#1019tompng merged 2 commits intoruby:masterfrom
tompng merged 2 commits intoruby:masterfrom
Conversation
Before change:
```console
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'
/Users/zzz/src/github.com/ruby/irb/lib/irb.rb:1135: warning: literal string will be frozen in the future
```
After change:
```console
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'
```
Member
|
Actually, warning in However, making build_statement not modify the given argument improves readability and code quality. 👍 |
tompng
reviewed
Oct 14, 2024
lib/irb.rb
Outdated
| end | ||
|
|
||
| code.force_encoding(@context.io.encoding) | ||
| code.dup.force_encoding(@context.io.encoding) |
Member
There was a problem hiding this comment.
This statement has no effect. We need to change the encoding of code.
maybe code = code.dup.force_encoding(@context.io.encoding)
Contributor
Author
There was a problem hiding this comment.
Thanks for your review and suggestion! I fixed them at
37fe153.
By the way, I met the warning in SciRuby/iruby's test code, SciRuby/iruby's code.
Because improves readability and code quality. Co-authored-by: tomoya ishida <[email protected]>
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Oct 18, 2024
warning (ruby/irb#1019) * Suppress "literal string will be frozen in the future" warning Before change: ```console $ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")' /Users/zzz/src/github.com/ruby/irb/lib/irb.rb:1135: warning: literal string will be frozen in the future ``` After change: ```console $ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")' ``` * Making build_statement not modify the given argument Because improves readability and code quality. Co-authored-by: tomoya ishida <[email protected]> --------- ruby/irb@3da04b9786 Co-authored-by: tomoya ishida <[email protected]>
Contributor
Author
|
I was deeply impressed by your keynote at RubyKaigi 2024 in person. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before change:
After change:
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'