Issue #11473 has been updated by Eregon (Benoit Daloze).


headius (Charles Nutter) wrote:
> If we make the global default to freeze string literals, would `frozen-string-literal: false` for a given file make them mutable?

Yes, in fact shortly after `--enable-frozen-string-literal` was introduced, most stdlib files got a `frozen-string-literal: false` so they would still work with that flag enabled:
https://github.com/ruby/ruby/commit/3e92b635fb5422207b7bbdc924e292e51e21f040

There are still 906 usages of `frozen_string_literal: false` in the MRI codebase as of today BTW (312 in stdlib files, the rest in tests).

I agree frozen String literals by default would be nice.
I'm not sure how much would be the compatibility impact.

Maybe we should gather some statistics in e.g. popular gems and all gems for how much files use the `frozen-string-literal` pragma.
Another way would be to run the test suites of a set of gems and see how much breaks with `--enable-frozen-string-literal`, including gems not using the pragma.

----------------------------------------
Feature #11473: Immutable String literal in Ruby 3
https://bugs.ruby-lang.org/issues/11473#change-81752

* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Matz said "All String literals are immutable (frozen) on Ruby 3".

This ticket is place holder to discuss about that.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>