Skip to content

Fix constant name of Ractor::IsolationError message #9422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2024

Conversation

yui-knk
Copy link
Contributor

@yui-knk yui-knk commented Jan 5, 2024

Fix constant name of Ractor::IsolationError messages:

# shareable_constant_value: literal
::C = ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to  (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
# shareable_constant_value: literal
::C ||= ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to C (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)

@yui-knk yui-knk force-pushed the fix_const_decl_path branch from a377ca0 to e6ff28c Compare January 6, 2024 15:32
If lhs of assignment is top-level constant reference, the first
constant name is omitted from error message.
This commit fixes it.

```
# shareable_constant_value: literal
::C = ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to  (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
```
`dest` of `const_decl_path` is `NODE_COLON2` or `NODE_COLON3` in some cases.
For example, `B::C ||= [“Not ” + “shareable”]` passes `NODE_COLON2`
and `::C ||= [“Not ” + “shareable”]` passes `NODE_COLON3`.
This commit fixes `Ractor::IsolationError` message for such case.

```
# shareable_constant_value: literal
::C ||= ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to C (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
```
@yui-knk yui-knk force-pushed the fix_const_decl_path branch from e6ff28c to b075bfe Compare February 9, 2024 12:19
@yui-knk yui-knk changed the title Include the first constant name into Ractor::IsolationError message Fix constant name of Ractor::IsolationError message Feb 10, 2024
@yui-knk yui-knk merged commit ea91ab6 into ruby:master Feb 10, 2024
@yui-knk yui-knk deleted the fix_const_decl_path branch February 10, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant