-
Notifications
You must be signed in to change notification settings - Fork 121
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
Suppress "literal string will be frozen in the future" warning #1019
Suppress "literal string will be frozen in the future" warning #1019
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")' ```
Actually, warning in However, making build_statement not modify the given argument improves readability and code quality. 👍 |
lib/irb.rb
Outdated
@@ -1132,7 +1132,7 @@ def build_statement(code) | |||
return Statement::EmptyInput.new | |||
end | |||
|
|||
code.force_encoding(@context.io.encoding) | |||
code.dup.force_encoding(@context.io.encoding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement has no effect. We need to change the encoding of code
.
maybe code = code.dup.force_encoding(@context.io.encoding)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <tomoyapenguin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
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 <tomoyapenguin@gmail.com> --------- ruby/irb@3da04b9786 Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
I was deeply impressed by your keynote at RubyKaigi 2024 in person. |
Before change:
After change:
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'