ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:71598] [Ruby trunk - Bug #11718] [Open] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
@ 2015-11-20  2:38 ` vsalikhov
  2015-11-20  6:25 ` [ruby-core:71600] [Ruby trunk - Bug #11718] " hanmac
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: vsalikhov @ 2015-11-20  2:38 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been reported by Vais Salikhov.

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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71600] [Ruby trunk - Bug #11718] Constant access on `nil`
       [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
  2015-11-20  9:18 ` [ruby-core:71605] " eregontp
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: hanmac @ 2015-11-20  6:25 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71605] [Ruby trunk - Bug #11718] Constant access on `nil`
       [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 ` [ruby-core:71600] [Ruby trunk - Bug #11718] " hanmac
@ 2015-11-20  9:18 ` eregontp
  2015-11-20  9:45 ` [ruby-core:71606] " hanmac
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: eregontp @ 2015-11-20  9:18 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Benoit Daloze.


I think this should really raise an error like:

    $ ruby -e 'p nil::String'
    -e:1:in `<main>': nil is not a class/module (TypeError)


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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71606] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-11-20  9:18 ` [ruby-core:71605] " eregontp
@ 2015-11-20  9:45 ` hanmac
  2015-11-23 14:25 ` [ruby-core:71640] " elia
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: hanmac @ 2015-11-20  9:45 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Hans Mackowiak.


yeah that should raise an error. A little test shows that this exist a while way back:

```ruby
p nil::String
```

for 1.9.3:

```ruby
String
```

for 1.8.7:

```ruby
# is not a class/module (TypeError)
```


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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71640] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-11-20  9:45 ` [ruby-core:71606] " hanmac
@ 2015-11-23 14:25 ` elia
  2015-11-23 14:40 ` [ruby-core:71641] " eregontp
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: elia @ 2015-11-23 14:25 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Elia Schito.


looks like it's somehow intended behavior

https://github.com/ruby/ruby/blob/trunk/insns.def#L179-L190

      /**
        @c variable
        @e
         Get constant variable id. If klass is Qnil, constants
         are searched in the current scope. If klass is Qfalse, constants
         are searched as top level constants. Otherwise, get constant under klass
         class or module.
        @j 定数 id の値を得る。
         klass が Qnil なら、そのスコープで得られる定数の値を得る。
         Qfalse なら、トップレベルスコープを得る。
         それ以外なら、klass クラスの下の定数を得る。
       */

apparently introduced here: https://github.com/ruby/ruby/commit/d84f9b16946bca06ce0557ebe99152d7d445c9ec to resolve bug #10943

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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71641] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-11-23 14:25 ` [ruby-core:71640] " elia
@ 2015-11-23 14:40 ` eregontp
  2015-11-24  9:23 ` [ruby-core:71649] " ko1
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: eregontp @ 2015-11-23 14:40 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Benoit Daloze.


I don't think it's intended, that commit should not introduce new behavior except on singleton class constants.
@ko1: Could you confirm this is a bug?

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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71649] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-11-23 14:40 ` [ruby-core:71641] " eregontp
@ 2015-11-24  9:23 ` ko1
  2015-12-07  7:57 ` [ruby-core:71894] " ko1
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: ko1 @ 2015-11-24  9:23 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Koichi Sasada.


This is a (intentional) bug. Because I expect nobody reveal such code :p


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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71894] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2015-11-24  9:23 ` [ruby-core:71649] " ko1
@ 2015-12-07  7:57 ` ko1
  2015-12-07 10:51 ` [ruby-core:71900] " ko1
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: ko1 @ 2015-12-07  7:57 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Koichi Sasada.

Assignee set to Koichi Sasada

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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71900] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2015-12-07  7:57 ` [ruby-core:71894] " ko1
@ 2015-12-07 10:51 ` ko1
  2015-12-08  6:41 ` [ruby-core:71940] " hanmac
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: ko1 @ 2015-12-07 10:51 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:71940] [Ruby trunk - Bug #11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2015-12-07 10:51 ` [ruby-core:71900] " ko1
@ 2015-12-08  6:41 ` hanmac
  2019-08-14  5:51 ` [ruby-core:94338] [Ruby master Bug#11718] " merch-redmine
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: hanmac @ 2015-12-08  6:41 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by Hans Mackowiak.


@Koichi: good that you classify it, for a moment i thought that might be an feature ;P

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

* 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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:94338] [Ruby master Bug#11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2015-12-08  6:41 ` [ruby-core:71940] " hanmac
@ 2019-08-14  5:51 ` merch-redmine
  2019-08-14  6:35 ` [ruby-core:94340] " ko1
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: merch-redmine @ 2019-08-14  5:51 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by jeremyevans0 (Jeremy Evans).

File nil-const-access-11718.patch added

This bug is still present in the master branch.  Attached is a patch that fixes it.  It adds a second argument to the getconstant instruction.  It would probably be better for performance to add a separate instruction for the case where this is needed, but I'm not sure it is worth it.  With the patch:

```ruby
nil::Object
# TypeError (nil is not a class/module)
```


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

* Author: vais (Vais Salikhov)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* 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!

---Files--------------------------------
nil-const-access-11718.patch (5.32 KB)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:94340] [Ruby master Bug#11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2019-08-14  5:51 ` [ruby-core:94338] [Ruby master Bug#11718] " merch-redmine
@ 2019-08-14  6:35 ` ko1
  2019-08-14  7:19 ` [ruby-core:94344] " nobu
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: ko1 @ 2019-08-14  6:35 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by ko1 (Koichi Sasada).


:+1: great patch! could you commit it?


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

* Author: vais (Vais Salikhov)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* 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!

---Files--------------------------------
nil-const-access-11718.patch (5.32 KB)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:94344] [Ruby master Bug#11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-08-14  6:35 ` [ruby-core:94340] " ko1
@ 2019-08-14  7:19 ` nobu
  2019-08-14 16:08 ` [ruby-core:94352] " merch-redmine
  2019-08-14 18:03 ` [ruby-core:94353] " ko1
  14 siblings, 0 replies; 15+ messages in thread
From: nobu @ 2019-08-14  7:19 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by nobu (Nobuyoshi Nakada).


I think it can be an operand of `getconst` than an argument on the stack, while it is always a constant.

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

* Author: vais (Vais Salikhov)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* 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!

---Files--------------------------------
nil-const-access-11718.patch (5.32 KB)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:94352] [Ruby master Bug#11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2019-08-14  7:19 ` [ruby-core:94344] " nobu
@ 2019-08-14 16:08 ` merch-redmine
  2019-08-14 18:03 ` [ruby-core:94353] " ko1
  14 siblings, 0 replies; 15+ messages in thread
From: merch-redmine @ 2019-08-14 16:08 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by jeremyevans0 (Jeremy Evans).


nobu: I agree, making it an operand instead of a stack argument makes more sense.  I'm currently testing a patch for that and will commit if it passes.

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

* Author: vais (Vais Salikhov)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* 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!

---Files--------------------------------
nil-const-access-11718.patch (5.32 KB)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [ruby-core:94353] [Ruby master Bug#11718] Constant access on `nil`
       [not found] <redmine.issue-11718.20151120023829@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2019-08-14 16:08 ` [ruby-core:94352] " merch-redmine
@ 2019-08-14 18:03 ` ko1
  14 siblings, 0 replies; 15+ messages in thread
From: ko1 @ 2019-08-14 18:03 UTC (permalink / raw)
  To: ruby-core

Issue #11718 has been updated by ko1 (Koichi Sasada).


> I think it can be an operand of getconst than an argument on the stack, while it is always a constant.

No. It should not be an new operand because we need to change tools which depends on current bytecode.

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

* Author: vais (Vais Salikhov)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* 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!

---Files--------------------------------
nil-const-access-11718.patch (5.32 KB)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-08-14 18:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 ` [ruby-core:71600] [Ruby trunk - Bug #11718] " hanmac
2015-11-20  9:18 ` [ruby-core:71605] " 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

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).