ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: hanmac@gmx.de
To: ruby-core@ruby-lang.org
Subject: [ruby-core:71600] [Ruby trunk - Bug #11718] Constant access on `nil`
Date: Fri, 20 Nov 2015 06:25:07 +0000	[thread overview]
Message-ID: <redmine.journal-54983.20151120062507.c56afa8351c11343@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11718.20151120023829@ruby-lang.org

Issue #11718 has been updated by Hans Mackowiak.


hm it might be that ```nil::Foo``` is parsed as ```::Foo``` which is doing the top-level access.

but i am not deep enough in the parser to fix that.

----------------------------------------
Bug #11718: Constant access on `nil`
https://bugs.ruby-lang.org/issues/11718#change-54983

* Author: Vais Salikhov
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
It is possible to access top-level constants by doing `nil::CONSTANT`, which looks like a bug [according to Matz](https://github.com/opal/opal/issues/1197#issuecomment-158078778). Here are a couple of examples:

```
$ ruby -ve "Foo = 123; p nil::Foo"
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
123
```

```
$ ruby -ve "class A; Foo = 456; end; p nil::A::Foo"
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
456
```

Thanks!



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2015-11-20  5:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
2015-11-20  2:38 ` [ruby-core:71598] [Ruby trunk - Bug #11718] [Open] Constant access on `nil` vsalikhov
2015-11-20  6:25 ` hanmac [this message]
2015-11-20  9:18 ` [ruby-core:71605] [Ruby trunk - Bug #11718] " eregontp
2015-11-20  9:45 ` [ruby-core:71606] " hanmac
2015-11-23 14:25 ` [ruby-core:71640] " elia
2015-11-23 14:40 ` [ruby-core:71641] " eregontp
2015-11-24  9:23 ` [ruby-core:71649] " ko1
2015-12-07  7:57 ` [ruby-core:71894] " ko1
2015-12-07 10:51 ` [ruby-core:71900] " ko1
2015-12-08  6:41 ` [ruby-core:71940] " hanmac
2019-08-14  5:51 ` [ruby-core:94338] [Ruby master Bug#11718] " merch-redmine
2019-08-14  6:35 ` [ruby-core:94340] " ko1
2019-08-14  7:19 ` [ruby-core:94344] " nobu
2019-08-14 16:08 ` [ruby-core:94352] " merch-redmine
2019-08-14 18:03 ` [ruby-core:94353] " ko1

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.journal-54983.20151120062507.c56afa8351c11343@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).