Project

General

Profile

« Previous | Next » 

Revision 43aee339

Added by ko1 (Koichi Sasada) over 1 year ago

fix defined?(@ivar) with Ractors

defined?(@ivar) on the non main Ractor has two issues:

  1. raising an exception
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.

  1. 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