From: "znz (Kazuhiro NISHIYAMA) via ruby-core" Date: 2026-11-04T23:58:56+00:00 Subject: [ruby-core:127337] [Ruby Bug#22507] `Ractor.new(&method_proc)` raises RuntimeError "not supported yet" since [Feature #22444]: NEWS entry and error class? Issue #22507 has been reported by znz (Kazuhiro NISHIYAMA). ---------------------------------------- Bug #22507: `Ractor.new(&method_proc)` raises RuntimeError "not supported yet" since [Feature #22444]: NEWS entry and error class? https://bugs.ruby-lang.org/issues/22507 * Author: znz (Kazuhiro NISHIYAMA) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-04T15:37:16Z HEAD 5888302d4f) +PRISM [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Since [Feature #22444] (commit [1f3e810694](https://github.com/ruby/ruby/commit/1f3e810694485f284871aee695a1a9d15467c983) and the follow-up [5c06c513ec](https://github.com/ruby/ruby/commit/5c06c513ec)), passing a method proc to `Ractor.new` raises `RuntimeError (not supported yet)`. On Ruby 4.0 it ran. Symbol procs still work. ```ruby o = Object.new def o.m = 1 p Ractor.new(&o.method(:m).to_proc).value p Ractor.new(&1.method(:succ).to_proc).value p Ractor.new(1, &:succ).value ``` ``` $ ruby -v ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux] $ ruby test.rb 1 2 2 $ ruby -v ruby 4.1.0dev (2026-11-04T15:37:16Z HEAD 5888302d4f) +PRISM [x86_64-linux] $ ruby test.rb test.rb:3:in 'Ractor.new': not supported yet (RuntimeError) ``` (`Ractor.new(&1.method(:succ).to_proc)` raises the same `RuntimeError`; `Ractor.new(1, &:succ)` returns 2 on both.) The commit message of 5c06c513ec says this is deliberate: "Method procs passed to Ractor.new now raise RuntimeError (not supported yet), like Ractor.shareable_proc; they previously ran unisolated with their receiver." So I am not reporting it as a regression, but I have three questions, mainly for documenting Ruby 4.1: 1. NEWS: the [Feature #22444] entry only describes the relaxed outer-variable rule. Should the incompatibility (method procs are now rejected by `Ractor.new`, including ones whose receiver is shareable) be listed in NEWS, so that 4.1 users can find it? 2. Error class and message: the other rejections of `Ractor.new` raise `Ractor::IsolationError` with a message that explains what to change ("cannot make a shareable Proc because the outer variable 'x' may be reassigned." etc.), while this one is a plain `RuntimeError` with "not supported yet" from `rb_proc_ractor_make_shareable`. Code that rescues `Ractor::IsolationError` around `Ractor.new` will not catch it. Would `Ractor::IsolationError` (for example "cannot make a shareable Proc from a method proc") be more appropriate? 3. Is rejecting every method proc the intended final state, or could a method proc whose receiver is shareable (such as `1.method(:succ).to_proc`) be accepted, as Symbol procs are? Reproduced in the `ghcr.io/ruby/ruby:master` and `ghcr.io/ruby/all-ruby` Docker images (x86_64-linux). The Japanese reference manual change for the new isolation rule is https://github.com/rurema/doctree/pull/3716. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/