Skip to content

Commit 5915b45

Browse files
authored
Update str_chilled_p for Ruby 4.1 (#219)
Ref: ruby/ruby#17781 [[Feature #22137]](https://bugs.ruby-lang.org/issues/22137) The only cause for chilled is now literals. `STR_CHILLED_SYMBOL_TO_S` has been removed because `Symbol#to_s` always return a frozen string.
1 parent 1b2ee56 commit 5915b45

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ext/stringio/stringio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ STRINGIO_VERSION = "3.2.1";
3939
static inline bool
4040
str_chilled_p(VALUE str)
4141
{
42-
#if (RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 4) || RUBY_API_VERSION_MAJOR >= 4
42+
#if RUBY_API_VERSION_CODE >= 40100
43+
// Do not attempt to modify chilled strings on Ruby 4.1+
44+
// RUBY_FL_USER2 == STR_CHILLED
45+
return FL_TEST_RAW(str, RUBY_FL_USER2);
46+
#elif RUBY_API_VERSION_CODE >= 30400
4347
// Do not attempt to modify chilled strings on Ruby 3.4+
4448
// RUBY_FL_USER2 == STR_CHILLED_LITERAL
4549
// RUBY_FL_USER3 == STR_CHILLED_SYMBOL_TO_S

0 commit comments

Comments
 (0)