From 7a094146e6ef38453a7e475450d90a9c83ea2277 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 19 Dec 2020 20:42:58 +0900 Subject: Changed shareable literal semantics [Feature #17397] When `literal`, check if the literal about to be assigned to a constant is ractor-shareable, otherwise raise `Ractor::Error` at runtime instead of `SyntaxError`. --- test/ruby/test_parse.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index ecacdebc70..0a1e3edc66 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1213,11 +1213,13 @@ x = __ENCODING__ assert_equal([1], a[0]) assert_send([Ractor, :shareable?, a[0]]) - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /unshareable expression/) - begin; - # shareable_constant_value: literal - C = ["Not " + "shareable"] - end; + assert_raise_with_message(Ractor::Error, /unshareable/) do + Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: literal + C = ["Not " + "shareable"] + end; + end end =begin -- cgit v1.2.3