Project

General

Profile

Bug #8189

(one more) inconsistency between Class and Module as namespaces

Added by Alexey Muranov about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:53841]

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

History

#1 [ruby-core:53842] Updated by Alexey Muranov about 3 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 [ruby-core:53846] Updated by Nobuyoshi Nakada about 3 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF