Actions
Bug #10488
closedConsistency of Module#const_defined? and constant lookup
Bug #10488:
Consistency of Module#const_defined? and constant lookup
Description
Currently, if for some module mod and constant Const,
mod.const_defined?(:Const) is true does not imply mod::Const is not an error.
This is inconsistent for at least the following cases:
-
if mod is a Module but not a class,
const_defined?will look inObjectand its ancestors, but constant access (::) will not look inObjector above. -
if
Constis private,const_defined?will return true whilemod::Constwill raise an error.
Is this intended?
Should it not mirror the behavior of defined?(mod::Const)?
Or the behavior of method_defined?
Actions