diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-09-25 18:31:04 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-09-25 20:37:38 +0900 |
commit | caaa36b4e6d0d59f0aa21049c063b140aa5aae4f (patch) | |
tree | 51e95c8e7be7a1a1793ab02a4c9f3a2cf2e1867f /bootstraptest | |
parent | 890bc2cdde4097390f3b71dfeaa36dd92ee0afe2 (diff) |
prohibi method call by defined_method in other racotrs
We can not call a non-isolated Proc in multiple ractors.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3584
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_ractor.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index ff99521a76..a71f00672b 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -724,6 +724,17 @@ assert_equal 'can not set constants with non-shareable objects by non-main Racto end } +# define_method is not allowed +assert_equal "defined in a different Ractor", %q{ + str = "foo" + define_method(:buggy){|i| str << "#{i}"} + begin + Ractor.new{buggy(10)}.take + rescue => e + e.cause.message + end +} + # Immutable Array and Hash are shareable, so it can be shared with constants assert_equal '[1000, 3]', %q{ A = Array.new(1000).freeze # [nil, ...] |