[Bug #21551] - Change Ractor Proc isolation error from ArgumentError to Ractor::IsolationError - #16163
Merged
ko1 merged 1 commit intoFeb 13, 2026
Conversation
Contributor
|
Thank you! |
This was referenced Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes https://bugs.ruby-lang.org/issues/21551
When
Ractor.newis called with a block that references outer variables, the error raised is anArgumentError. Because ErrorHighlight treatsArgumentErrorspecially (highlighting the arguments of the method call) the squiggly underline points to the wrong place.The squiggly points at
channelinRactor.new(channel), which is the correct way to pass data into a Ractor. The actual problem ischannelbeing referenced inside the block body without a corresponding block parameter|channel|.This happens because
ErrorHighlightsetspoint_type: :argsforArgumentError, which tells it to highlight the arguments of the call (it doesn't highlight just channel).Solution
I'm proposing a multi-step approach:
Step 1: Raise
Ractor::IsolationErrorinstead ofArgumentError[this PR changes] ⭐Ractor.shareable_procraisesRactor::IsolationErrorfor a similar situation - a Proc that references outer variables that can't be shared.Step 2: Enhance
Ractor::IsolationErrorto hold a reference to the list of outer variables used in the proc [Next PRs] 📝Enrich the exception class with the list of outer variables referenced in the Proc, so that this information is available to ErrorHighlight.
Step 3: Create a custom error highlitghting case for
Ractor::IsolationErrorso we can highlight the uses of these [Next PRs] variables inside the proc 📝Use the variable information from step 2 to highlight the actual uses of the outer variables inside the block body, rather than the call site.