Bug #8189

(one more) inconsistency between Class and Module as namespaces

Added by Alexey Muranov over 2 years ago. Updated over 2 years ago.

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 over 2 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.

#2 Updated by Nobuyoshi Nakada over 2 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF