diff options
author | Koichi Sasada <[email protected]> | 2021-12-09 04:06:53 +0900 |
---|---|---|
committer | Marc-André Lafortune <@marc-andre.ca> | 2021-12-08 14:47:46 -0500 |
commit | 9c269316357a1a5b6ef27794f3c9412b2e33a6cd () | |
tree | de3baa4722547b95fe595355f1d07e68ba22e251 /lib/ostruct.rb | |
parent | 9a2ecddf32528286c81ca87db1d17c85aca4e754 (diff) |
[ruby/ostruct] `Proc`'s self should be shareable.
To fix the issue https://bugs.ruby-lang.org/issues/18243 we need to make sure the Proc's self is shareable. These procs are used by `define_method` and it doesn't use Proc's self, so `nil` is enough.
-rw-r--r-- | lib/ostruct.rb | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -221,11 +221,14 @@ class OpenStruct # def new_ostruct_member!(name) # :nodoc: unless @table.key?(name) || is_method_protected!(name) - getter_proc = Proc.new { @table[name] } - setter_proc = Proc.new {|x| @table[name] = x} if defined?(::Ractor) ::Ractor.make_shareable(getter_proc) ::Ractor.make_shareable(setter_proc) end define_singleton_method!(name, &getter_proc) define_singleton_method!("#{name}=", &setter_proc) |