Bug #8189
closed(one more) inconsistency between Class and Module as namespaces
Description
=begin
(I will only mention in parentheses that inheriting (({Class})) from (({Module})) looks like a bad idea to me, i would have preferred that both inherited from some (({Namespace})) class.)
While trying to answer ((<this SO question|URL:http://stackoverflow.com/questions/6254496/is-it-possible-to-give-a-sub-module-the-same-name-as-a-top-level-class/15716986#15716986>)), i have noticed the following inconsistent behavior between classes and modules used as namespaces:
A = 0
class C; end
module M; end
C::A # warning: toplevel constant A referenced by C::A
M::A # uninitialized constant M::A (NameError)
=end
Updated by alexeymuranov (Alexey Muranov) about 11 years ago
I have thought more about it, and i have remembered that a class constant lookup also follows the inheritance hierarchy. Then probably this is not a bug. To me it is a bit unexpected in any case.
Updated by nobu (Nobuyoshi Nakada) about 11 years ago
- Status changed from Open to Closed