Skip to content
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

Use <<~ (squiggly heredoc) to address warning: literal string will be frozen in the future #544

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Oct 23, 2024

This commit addresses the warning: literal string will be frozen in the future against Ruby 3.4.0dev

ruby 3.4.0dev (2024-10-21T16:48:53Z master 5131fb5dbe) +PRISM [x86_64-linux]
$ RUBYOPT="--debug-frozen-string-literal" bundle exec rake test TEST=test/test_quiet_assets.rb
  • Warnings addressed by this commit
/path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:24: warning: literal string will be frozen in the future
/path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:23: info: the string was created here
  • Sprockets Rails requires Ruby 2.5 that supports <<~ (squiggly heredoc) introduced since Ruby 2.3.

https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/ https://github.com/ruby/ruby/blob/d40ea2afa6ff5a6e5befcf342fb7b6dc58796b20/NEWS?plain=1#L53-L57 ruby/ruby#11893

@yahonda
Copy link
Member Author

yahonda commented Oct 23, 2024

… be frozen in the future`

This commit addresses the `warning: literal string will be frozen in the future`

```$ ruby -v
ruby 3.4.0dev (2024-10-21T16:48:53Z master 5131fb5dbe) +PRISM [x86_64-linux]
$ RUBYOPT="--debug-frozen-string-literal" bundle exec rake test TEST=test/test_quiet_assets.rb
```

- Warnings addressed by this commit
```ruby
/path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:24: warning: literal string will be frozen in the future
/path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:23: info: the string was created here
```

- Sprockets Rails requires Ruby 2.5 that supports `<<~` (squiggly heredoc) introduced since Ruby 2.3.

https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/
https://github.com/ruby/ruby/blob/d40ea2afa6ff5a6e5befcf342fb7b6dc58796b20/NEWS?plain=1#L53-L57
ruby/ruby#11893

- `--debug-frozen-string-literal` option has been introduced via ruby/ruby#11893
@yahonda yahonda changed the title Use <<~ (squiggly heredoc) to address `warning: literal string will be frozen in the future Use <<~ (squiggly heredoc) to address warning: literal string will be frozen in the future` Oct 23, 2024
@yahonda yahonda changed the title Use <<~ (squiggly heredoc) to address warning: literal string will be frozen in the future` Use <<~ (squiggly heredoc) to address warning: literal string will be frozen in the future Oct 23, 2024
@yahonda yahonda merged commit 266ec49 into rails:master Oct 23, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants