diff options
author | Jean byroot Boussier <jean.boussier+github@shopify.com> | 2024-11-13 15:20:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-13 09:20:00 -0500 |
commit | 6deeec5d459ecff5ec4628523b14ac7379fd942e (patch) | |
tree | 1815b684da615359165055c3a12df4dca45a1ae7 /object.c | |
parent | 37a16c7812f5b7e6faa762b927e9f04065cc495a (diff) |
Mark strings returned by Symbol#to_s as chilled (#12065)
* Use FL_USER0 for ELTS_SHARED
This makes space in RString for two bits for chilled strings.
* Mark strings returned by `Symbol#to_s` as chilled
[Feature #20350]
`STR_CHILLED` now spans on two user flags. If one bit is set it
marks a chilled string literal, if it's the other it marks a
`Symbol#to_s` chilled string.
Since it's not possible, and doesn't make much sense to include
debug info when `--debug-frozen-string-literal` is set, we can't
include allocation source, but we can safely include the symbol
name in the warning message, making it much easier to find the source
of the issue.
Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
---------
Co-authored-by: Étienne Barrié <etienne.barrie@gmail.com>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -500,10 +500,12 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze) case Qnil: rb_funcall(clone, id_init_clone, 1, obj); RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE; - if (CHILLED_STRING_P(obj)) { - STR_CHILL_RAW(clone); + + if (RB_TYPE_P(obj, T_STRING)) { + FL_SET_RAW(clone, FL_TEST_RAW(obj, STR_CHILLED)); } - else if (RB_OBJ_FROZEN(obj)) { + + if (RB_OBJ_FROZEN(obj)) { rb_shape_t * next_shape = rb_shape_transition_shape_frozen(clone); if (!rb_shape_obj_too_complex(clone) && next_shape->type == SHAPE_OBJ_TOO_COMPLEX) { rb_evict_ivars_to_hash(clone); |