mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
![]() [Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <byroot@ruby-lang.org> |
||
---|---|---|
.. | ||
-ext- | ||
.excludes | ||
.excludes-prism | ||
benchmark | ||
cgi | ||
coverage | ||
date | ||
did_you_mean | ||
digest | ||
dtrace | ||
erb | ||
error_highlight | ||
etc | ||
fiber | ||
fiddle | ||
fileutils | ||
io | ||
irb | ||
json | ||
lib | ||
logger | ||
mkmf | ||
monitor | ||
net | ||
objspace | ||
open-uri | ||
openssl | ||
optparse | ||
ostruct | ||
pathname | ||
prism | ||
psych | ||
rdoc | ||
reline | ||
resolv | ||
ripper | ||
ruby | ||
rubygems | ||
set | ||
socket | ||
stringio | ||
strscan | ||
uri | ||
win32ole | ||
yaml | ||
zlib | ||
runner.rb | ||
test_delegate.rb | ||
test_extlibs.rb | ||
test_find.rb | ||
test_forwardable.rb | ||
test_ipaddr.rb | ||
test_open3.rb | ||
test_pp.rb | ||
test_prettyprint.rb | ||
test_pstore.rb | ||
test_pty.rb | ||
test_rbconfig.rb | ||
test_securerandom.rb | ||
test_shellwords.rb | ||
test_singleton.rb | ||
test_tempfile.rb | ||
test_time.rb | ||
test_timeout.rb | ||
test_tmpdir.rb | ||
test_trick.rb | ||
test_tsort.rb | ||
test_unicode_normalize.rb | ||
test_weakref.rb |