Bug #8189

(one more) inconsistency between Class and Module as namespaces

Added by Alexey Muranov about 1 year ago. Updated about 1 year ago.

Target version:-
ruby -v:2.0.0 Backport:


(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 (()), 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)


#1 Updated by Alexey Muranov about 1 year 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.

#2 Updated by Nobuyoshi Nakada about 1 year ago

  • Status changed from Open to Closed

Also available in: Atom PDF