Project

General

Profile

Actions

Bug #11055

closed

autoload resets private_constant

Added by nobu (Nobuyoshi Nakada) over 9 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:<unknown>]

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

const-visibility-before-autoload-11055.patch (3.93 KB) const-visibility-before-autoload-11055.patch jeremyevans0 (Jeremy Evans), 08/12/2019 03:59 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0