From: marcandre-ruby-core@... Date: 2020-12-17T00:59:09+00:00 Subject: [ruby-core:101483] [Ruby master Feature#17401] The class `Ractor::MovedObject` should not be frozen Issue #17401 has been reported by marcandre (Marc-Andre Lafortune). ---------------------------------------- Feature #17401: The class `Ractor::MovedObject` should not be frozen https://bugs.ruby-lang.org/issues/17401 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: ko1 (Koichi Sasada) ---------------------------------------- If `Ractor::MovedObject` can be not frozen that would be more helpful than currently. For example, to implement a helpful `inspect` in pure Ruby 3.0 like in #17393 It is currently possible to go around the fact that it is frozen with refinements: ```ruby using Module.new { refine Ractor::MovedObject do def inspect "I was moved! Don't use me!" end end } o = Object.new Ractor.new{ receive }.send(o, move:true) puts o.inspect # => "I was moved! Don't use me!" ``` Another (ugly) way to bypass the fact that it is frozen without refinements is to modify its ancestor: ```ruby module Ext def inspect return super unless Ractor::MovedObject === self "I was moved! Don't use me!" end end BasicObject.prepend Ext o = Object.new Ractor.new{ receive }.send(o, move:true) p o # => "I was moved! Don't use me!" ``` My point remain that this "security" can be bypassed unless it is stricly necessary it, it would be nice to unfreeze the class. It could be documented that this is experimental / not recommended to modify the class in production, for example. -- https://bugs.ruby-lang.org/ Unsubscribe: