Issue #11705 has been reported by Mike Pastore.

----------------------------------------
Bug #11705: Namespace resolution in nested modules with short syntax
https://bugs.ruby-lang.org/issues/11705

* Author: Mike Pastore
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Given the following definition:

~~~
module Foo
  class Qux
    def self.hello
      'Hello, world!'
    end
  end
end
~~~

Namespace resolution at a later time works differently when you have nested modules, e.g.

~~~
module Foo
  module Bar
    # Can't find Foo::Bar::Qux, so "goes up" to find Foo::Qux.
    p Qux.hello # < "Hello, world!"
  end
end
~~~

vs. the short syntax, e.g. 

~~~
module Foo::Bar
  # Can't find Foo::Bar::Qux, but doesn't "go up" to find Foo::Qux.
  p Qux.hello # < in `<module:Bar>': uninitialized constant Foo::Bar::Qux (NameError)
end
~~~

Is this intentional and/or expected?



-- 
https://bugs.ruby-lang.org/