Project

General

Profile

Actions

Bug #11718

closed

Constant access on `nil`

Added by vais (Vais Salikhov) about 9 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
[ruby-core:71598]

Description

It is possible to access top-level constants by doing nil::CONSTANT, which looks like a bug according to Matz. 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!


Files

nil-const-access-11718.patch (5.32 KB) nil-const-access-11718.patch jeremyevans0 (Jeremy Evans), 08/14/2019 05:48 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0