[ruby-core:123062] [Ruby Bug#21551] Ractor isolation error points to the wrong place

ruby thing.rb
Issue #21551 has been reported by tenderlovemaking (Aaron Patterson). ---------------------------------------- Bug #21551: Ractor isolation error points to the wrong place https://bugs.ruby-lang.org/issues/21551 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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: ```ruby 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: ``` 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`. -- https://bugs.ruby-lang.org/
participants (1)
-
tenderlovemaking (Aaron Patterson)