Actions
Bug #14469
closedprivate_constant and deprecate_constant are ignored by autoloading
Description
Consider the following code in file "zzz.rb":
class ZZZ
P = D = 1
private_constant :P
deprecate_constant :D
end
After loading the file, accesses to ZZZ::P
and ZZZ:D
cause an exception and a warning respectively.
$ ruby -r./zzz -e ZZZ::P
Traceback (most recent call last):
-e:1:in `<main>': private constant ZZZ::P referenced (NameError)
$ ruby -r./zzz -e ZZZ::D
-e:1: warning: constant ZZZ::D is deprecated
But autoloading the file nothing happens.
$ ruby -e 'class ZZZ;autoload :P,"./zzz.rb";end; ZZZ::P'
$ ruby -e 'class ZZZ;autoload :D,"./zzz.rb";end; ZZZ::D'
After requiring the file in ordinary way, they works.
$ ruby -e 'class ZZZ;autoload :P,"./zzz.rb";end; require "./zzz.rb"; ZZZ::P'
Traceback (most recent call last):
-e:1:in `<main>': private constant ZZZ::P referenced (NameError)
$ ruby -e 'class ZZZ;autoload :D,"./zzz.rb";end; require "./zzz.rb"; ZZZ::D'
-e:1: warning: constant ZZZ::D is deprecated
Actions
Like0
Like0Like0Like0