From: eregontp@gmail.com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50954] [Ruby master Bug#9815] attr_reader doesn't warn on a uninitialized instance variable
Date: Wed, 02 Sep 2020 20:46:46 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-87379.20200902204645.17@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-9815.20140508092530.17@ruby-lang.org>
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/
parent reply other threads:[~2020-09-02 20:46 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <redmine.issue-9815.20140508092530.17@ruby-lang.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-87379.20200902204645.17@ruby-lang.org \
--to=eregontp@gmail.com \
--cc=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).