1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/psych] Suppress uninitialized instance variable warnings

In verbose mode, `test_delegator` in `test/psych/visitors/test_yaml_tree.rb` shows following warning.

https://travis-ci.org/ruby/psych/jobs/562435717#L268
```
/home/travis/build/ruby/psych/test/psych/visitors/test_yaml_tree.rb:10: warning: instance variable @obj not initialized
```

This is because `Psych.load` bypasses #initialize with the #init_with method.

https://github.com/ruby/psych/commit/f99523388f
This commit is contained in:
Nobuyoshi Nakada 2019-07-24 22:21:49 +09:00
parent 6ca7dc69ef
commit 698dde525a

View file

@ -7,7 +7,7 @@ module Psych
class TestDelegatorClass < Delegator
def initialize(obj); super; @obj = obj; end
def __setobj__(obj); @obj = obj; end
def __getobj__; @obj; end
def __getobj__; @obj if defined?(@obj); end
end
class TestSimpleDelegatorClass < SimpleDelegator