Issue #11718 has been updated by Koichi Sasada.


* This is a bug, so that anyone should not rely on this behavior.
* This is a bug, so that this bug should be fixed
* But not critical, so 2.3 can remain this behavior. It should be fix in a future.

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

* Author: Vais Salikhov
* Status: Open
* Priority: Normal
* Assignee: Koichi Sasada
* 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/