diff --git a/parse.y b/parse.y index 1637921a2b..c65a469a31 100644 --- a/parse.y +++ b/parse.y @@ -11085,7 +11085,7 @@ shareable_literal_value(NODE *node) } #ifndef SHAREABLE_BARE_EXPRESSION -#define SHAREABLE_BARE_EXPRESSION 0 +#define SHAREABLE_BARE_EXPRESSION 1 #endif VALUE rb_ractor_make_shareable(VALUE obj); diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index aeaa42dadb..2e3fbc9945 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1252,16 +1252,18 @@ x = __ENCODING__ end def test_shareable_constant_value_nonliteral - c, d = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") + assert_raise_separately(Ractor::IsolationError, /unshareable/, "#{<<~"begin;"}\n#{<<~'end;'}") begin; # shareable_constant_value: literal var = [:not_frozen] C = var - D = begin [] end - [C, D] end; - assert_not_ractor_shareable(c) - assert_not_ractor_shareable(d) + + assert_raise_separately(Ractor::IsolationError, /unshareable/, "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: literal + D = begin [] end + end; end def test_shareable_constant_value_unfrozen