https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112015-12-18T08:30:42ZRuby Issue Tracking SystemRuby master - Bug #11705: Namespace resolution in nested modules with short syntaxhttps://bugs.ruby-lang.org/issues/11705?journal_id=556522015-12-18T08:30:42Zshugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>Mike Pastore wrote:</p>
<blockquote>
<p>Is this intentional and/or expected?</p>
</blockquote>
<p>It's intentional and expected.</p>
<p>If class and/or module definitions are explicitly nested, constants of outer classes and/or modules are looked up.<br>
However, if a class or module definition is not nested, only constants in the class or module, its ancestors,<br>
and if the target is a module, <code>Object</code> and <code>Object</code>'s ancestors are looked up.</p>
<p>You can see module nesting information by <code>Module.nesting</code>.</p>
<pre><code>module Foo
module Bar
p Module.nesting #=> [Foo::Bar, Foo]
p Qux.hello #=> "Hello, world!"
end
end
module Foo::Bar
p Module.nesting #=> [Foo::Bar]
p Qux.hello #=> NameError, because Foo is not included in Module.nesting
end
</code></pre> Ruby master - Bug #11705: Namespace resolution in nested modules with short syntaxhttps://bugs.ruby-lang.org/issues/11705?journal_id=831992019-12-18T01:18:28Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-2 status-6 priority-4 priority-default closed" href="/issues/16430">Feature #16430</a>: Resultion of constants in enclosing class/module affected by how nested classes/modules are declared</i> added</li></ul>