summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTsutomu Katsube <[email protected]>2024-10-19 02:15:22 +0900
committergit <[email protected]>2024-10-18 17:15:25 +0000
commitf370a31578fa2545514af15f753309aa826d0ae8 (patch)
treef06334908f0c6f42dfd1d65abbeafd9dba630676 /lib
parent09ddfd4d1ce4c1ba08e05c02bd2a1ec6e046211d (diff)
[ruby/irb] Suppress "literal string will be frozen in the future"
warning (https://github.com/ruby/irb/pull/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]> --------- https://github.com/ruby/irb/commit/3da04b9786 Co-authored-by: tomoya ishida <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/irb.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index 12eb69c5b1..528892797f 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -1132,7 +1132,7 @@ module IRB
return Statement::EmptyInput.new
end
- code.force_encoding(@context.io.encoding)
+ code = code.dup.force_encoding(@context.io.encoding)
if (command, arg = @context.parse_command(code))
command_class = Command.load_command(command)
Statement::Command.new(code, command_class, arg)