Project

General

Profile

Actions

Bug #22507

open

`Ractor.new(&method_proc)` raises RuntimeError "not supported yet" since [Feature #22444]: NEWS entry and error class?

Bug #22507: `Ractor.new(&method_proc)` raises RuntimeError "not supported yet" since [Feature #22444]: NEWS entry and error class?

Added by znz (Kazuhiro NISHIYAMA) 2 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-11-04T15:37:16Z HEAD 5888302d4f) +PRISM [x86_64-linux]
[ruby-core:127337]

Description

Since [Feature #22444] (commit 1f3e810694 and the follow-up 5c06c513ec), passing a method proc to Ractor.new raises RuntimeError (not supported yet). On Ruby 4.0 it ran. Symbol procs still work.

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.

No data to display

Actions

Also available in: PDF Atom