Skip to content

Commit

Permalink
Suppress "literal string will be frozen in the future" warning
Browse files Browse the repository at this point in the history
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")'
```
  • Loading branch information
tikkss committed Oct 13, 2024
1 parent 5151467 commit 020c67c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if (command, arg = @context.parse_command(code))
command_class = Command.load_command(command)
Statement::Command.new(code, command_class, arg)
Expand Down

0 comments on commit 020c67c

Please sign in to comment.