Issue #11055 has been updated by matz (Yukihiro Matsumoto).


I agree with fixing this. Nobu will investigate the patch and consider the issue detail.

Matz.


----------------------------------------
Bug #11055: autoload resets private_constant
https://bugs.ruby-lang.org/issues/11055#change-82090

* Author: nobu (Nobuyoshi Nakada)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: 50203
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Is this behavior intentional?

Suppose the following file:

~~~
$ cat a/b.rb
class A; B = 1; end
~~~

This causes `NameError`.

~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; end' -e 'p A::B'
-e:2:in `<main>': private constant A::B referenced (NameError)
~~~

But after it got loaded, `A::B` becomes public.

~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; B; end' -e 'p A::B'
1
~~~


---Files--------------------------------
const-visibility-before-autoload-11055.patch (3.93 KB)


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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>