diff --git a/ractor.c b/ractor.c index 75371cfa6f..2388729f83 100644 --- a/ractor.c +++ b/ractor.c @@ -3163,7 +3163,7 @@ make_shareable_check_shareable(VALUE obj) return traverse_cont; } else { - rb_raise(rb_eRactorError, "can not make shareable object for %"PRIsVALUE, obj); + rb_raise(rb_eRactorError, "can not make shareable object for %+"PRIsVALUE, obj); } } diff --git a/test/ruby/test_ractor.rb b/test/ruby/test_ractor.rb index ec94df361f..e61c6beffc 100644 --- a/test/ruby/test_ractor.rb +++ b/test/ruby/test_ractor.rb @@ -60,6 +60,14 @@ class TestRactor < Test::Unit::TestCase assert_unshareable(x, "can not make shareable object for #", exception: Ractor::Error) end + def test_shareability_error_uses_inspect + x = (+"").instance_exec { method(:to_s) } + def x.to_s + raise "this should not be called" + end + assert_unshareable(x, "can not make shareable object for #", exception: Ractor::Error) + end + def test_default_thread_group assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin;