json-stream icon indicating copy to clipboard operation
json-stream copied to clipboard

support for forzen string literals

Open otegami opened this issue 1 year ago • 1 comments

Issue

When running tests with Ruby 3.4.0rc1, the following warnings are displayed.

$ rake test
Run options: --seed 46514

/work/ruby/json-stream/lib/json/stream/parser.rb:549: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/work/ruby/json-stream/lib/json/stream/parser.rb:555: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)

Causes

According to https://bugs.ruby-lang.org/issues/20205, string literals may be frozen by default in future Ruby versions (potentially Ruby 4.0+). Starting from Ruby 3.4.0, warnings like warning: literal string will be frozen in the future are shown if string literals are mutable.

Solution

We explicitly make string literals mutable using +"string literal" Additionally, we add # frozen_string_literal: true at the top of the affected files and handle the warnings to ensure compatibility with Ruby versions before 3.4.0.

otegami avatar Dec 24 '24 23:12 otegami

@dgraham Please consider #10 instead. Thanks.

sheldonh avatar Jul 28 '25 08:07 sheldonh