diff options
| author | Koichi Sasada <ko1@atdot.net> | 2024-07-11 05:59:14 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2024-07-12 04:43:14 +0900 |
| commit | 43aee3393d70f8893e312b38a9a30c1dba295c41 (patch) | |
| tree | 0bff897526b61ff20fe6f978628b2ff1366e5225 /include/ruby/debug.h | |
| parent | ef563a696db983fe21a259dac38e5bec201d6b9a (diff) | |
fix `defined?(@ivar)` with Ractors
`defined?(@ivar)` on the non main Ractor has two issues:
1. raising an exception
```ruby
class C
@iv1 = []
def self.defined_iv1 = defined?(@iv1)
end
Ractor.new{
p C.defined_iv1
#=> can not get unshareable values from instance variables of classes/modules from non-main Ractors (Ractor::IsolationError)
}.take
```
-> Do not raise an exception but return `"instance-variable"` because
it is defined.
2. returning `"instance-variable"` if there is not defined.
```
class C
# @iv2 is not defined
def self.defined_iv2 = defined?(@iv2)
end
Ractor.new{
p C.defined_iv2 #=> "instance-variable"
}.take
```
-> returns `nil`
Diffstat (limited to 'include/ruby/debug.h')
0 files changed, 0 insertions, 0 deletions
