From: "tenderlovemaking (Aaron Patterson) via ruby-core" Date: 2025-08-23T23:41:20+00:00 Subject: [ruby-core:123062] [Ruby Bug#21551] Ractor isolation error points to the wrong place 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: ``` > 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 '
' ``` 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/ ______________________________________________ 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/