[前][次][番号順一覧][スレッド一覧]

ruby-changes:56651

From: Nobuyoshi <ko1@a...>
Date: Thu, 25 Jul 2019 08:02:34 +0900 (JST)
Subject: [ruby-changes:56651] Nobuyoshi Nakada: 698dde525a (master): [ruby/psych] Suppress uninitialized instance variable warnings

https://git.ruby-lang.org/ruby.git/commit/?id=698dde525a

From 698dde525ad3df1444276ccd28c6349c81af2a19 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 24 Jul 2019 22:21:49 +0900
Subject: [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

diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 01f1aec..69885ee 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -7,7 +7,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/visitors/test_yaml_tree.rb#L7
       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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]