* [ruby-dev:50954] [Ruby master Bug#9815] attr_reader doesn't warn on a uninitialized instance variable
[not found] <redmine.issue-9815.20140508092530.17@ruby-lang.org>
@ 2020-09-02 20:46 ` eregontp
0 siblings, 0 replies; only message in thread
From: eregontp @ 2020-09-02 20:46 UTC (permalink / raw)
To: ruby-dev
Issue #9815 has been updated by Eregon (Benoit Daloze).
What was the rationale here to have different behavior?
Which C function is used by `attr_reader` seems an implementation detail.
----------------------------------------
Bug #9815: attr_reader doesn't warn on a uninitialized instance variable
https://bugs.ruby-lang.org/issues/9815#change-87379
* Author: ko1 (Koichi Sasada)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* ruby -v: confirmed by 1.9.3-2.2.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
attr_reader で定義したメソッドでは、-w 時に、未設定の警告「warning: instance variable @bar not initialized」みたいなのが出ないんですが、そういうもんでしょうか。
~~~ruby
class C
attr_reader :foo
def bar; @bar; end
end
C.new.foo
C.new.bar #=> t.rb:4: warning: instance variable @bar not initialized
~~~
この例では、foo と bar は、同じ意味だと思って居たのでびっくりした次第です。
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-02 20:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-9815.20140508092530.17@ruby-lang.org>
2020-09-02 20:46 ` [ruby-dev:50954] [Ruby master Bug#9815] attr_reader doesn't warn on a uninitialized instance variable eregontp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).