From: barrettkingram@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96586] [Ruby master Bug#16467] Fetching a class variable with instance_eval fails with NameError
Date: Mon, 30 Dec 2019 00:44:30 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-16467.20191230004429.46971e01a48b9f06@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16467.20191230004429@ruby-lang.org
Issue #16467 has been reported by barrettkingram (Barrett Ingram).
----------------------------------------
Bug #16467: Fetching a class variable with instance_eval fails with NameError
https://bugs.ruby-lang.org/issues/16467
* Author: barrettkingram (Barrett Ingram)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Trying to fetch a class variable using `instance_eval` fails with `uninitialized class variable @variable_name in Object (NameError)`.
Reproduction program:
``` ruby
class FooClass
def initialize
@foo = "foo"
@@bar = "bar"
end
def get_bar
@@bar
end
end
foo = FooClass.new
puts foo.instance_eval("@foo") # prints "foo"
puts foo.get_bar # prints "bar"
puts foo.instance_eval("@@bar") # raises uninitialized class variable @@bar in Object (NameError)
```
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2019-12-30 0:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16467.20191230004429@ruby-lang.org>
2019-12-30 0:44 ` barrettkingram [this message]
2019-12-30 9:05 ` [ruby-core:96591] [Ruby master Bug#16467] Fetching a class variable with instance_eval fails with NameError nobu
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-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-16467.20191230004429.46971e01a48b9f06@ruby-lang.org \
--to=ruby-core@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 read-only IMAP folder(s) and NNTP newsgroup(s).