Actions
Bug #11055
closedautoload resets private_constant
Bug #11055:
autoload resets private_constant
ruby -v:
50203
Description
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
Actions