Commit 9633bbe
committed
Include ivar name and class name in the Ractor isolation error message
- ### Problem
When a Ractor isolation error happens due to setting an ivar on a
class, the message doesn't include the name of the ivar and neither
the name of the class. It makes it difficult to track down where the
isolation problem comes from.
I'd like the message to be similar as what we get when a Ractor
access an unshareable ivar.
This is the current behaviour
```ruby
class Foo
def self.foo
@foo ||= "test"
end
end
Ractor.new do
Foo.foo # can not set instance variables of classes/modules by non-main Ractors
end.join
Foo.foo
Ractor.new do
Foo.foo # can not get unshareable values from instance variables of classes/modules from non-main Ractors (@foo from Foo)
end.join
```
### Solution
Modify the error message to include the ivar name and the class/module name.1 parent 1790ac4 commit 9633bbe
2 files changed
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
867 | 886 | | |
868 | 887 | | |
869 | 888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1199 | 1199 | | |
1200 | 1200 | | |
1201 | 1201 | | |
1202 | | - | |
| 1202 | + | |
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1207 | 1212 | | |
1208 | 1213 | | |
1209 | 1214 | | |
| |||
1595 | 1600 | | |
1596 | 1601 | | |
1597 | 1602 | | |
1598 | | - | |
| 1603 | + | |
1599 | 1604 | | |
1600 | 1605 | | |
1601 | 1606 | | |
| |||
1968 | 1973 | | |
1969 | 1974 | | |
1970 | 1975 | | |
1971 | | - | |
| 1976 | + | |
1972 | 1977 | | |
1973 | 1978 | | |
1974 | 1979 | | |
| |||
2262 | 2267 | | |
2263 | 2268 | | |
2264 | 2269 | | |
2265 | | - | |
| 2270 | + | |
2266 | 2271 | | |
2267 | 2272 | | |
2268 | 2273 | | |
| |||
0 commit comments