Project

General

Profile

Actions

Bug #21551

open

Ractor isolation error points to the wrong place

Added by tenderlovemaking (Aaron Patterson) 1 day ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:123062]

Description

The following code has a bug in it. The block passed to Ractor.new references the outer channel variable, so it can't be isolated. The problem is that I forgot to add |channel| to the block:

channel = Ractor::Port.new

coordinator = Ractor.new(channel) do
  inbound_work = Ractor::Port.new
  channel << inbound_work
end

However, the exception this raises is strange:

> ruby thing.rb
thing.rb:3: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
thing.rb:3:in 'Ractor.new': can not isolate a Proc because it accesses outer variables (channel). (ArgumentError)

coordinator = Ractor.new(channel) do
                         ^^^^^^^
	from thing.rb:3:in '<main>'

I would expect the channel local inside the block to be underlined instead of the parameter passed to Ractor.new.

No data to display

Actions

Also available in: Atom PDF

Like0