https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?15064139052012-11-21T03:17:24ZRuby Issue Tracking SystemRuby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=333562012-11-21T03:17:24Zrobertgleeson (Robert Gleeson)
<ul></ul><p>I realise defined? with a constant works just as well but this is about API consistency.<br>
I&#39;d expect const_get &amp; const_defined? to support the same syntax (&quot;Object::Foo&quot;).</p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=337502012-11-24T11:49:14Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>tenderlovemaking (Aaron Patterson)</i></li></ul><p>Aaron, can you fix it easily?</p>
<p>-- <br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp">mame@tsg.ne.jp</a></p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=343922012-12-04T16:35:40Zsferik (Erik Michaels-Ober)sferik@gmail.com
<ul></ul><p>I also noticed this inconsistency. It seems very odd to have different behavior for Module#const_get and Module#const_defined?. I hope it&#39;s possible to get this change into 2.0.0. It&#39;s been a while since I&#39;ve written any C but I&#39;d be happy to contribute failing specs if that would be helpful.</p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=348082012-12-18T04:35:39Zbenolee (Ben Holley)benolee@gmail.com
<ul></ul><p>I have been working on a patch, but I have some questions about expected behavior.</p>
<p>In the case when the parent is missing, for example:</p>
<pre># Foo is missing
Object.const_defined?(&quot;Foo::Bar&quot;)
</pre>
<p>should it return false? Or raise NameError for &quot;Foo&quot;? Or call Object.const_missing(:Foo)?</p>
<p>Second, in the case when the parent is not a Module or Class, for example:</p>
<pre>Foo = Object.new
Object.const_defined?(&quot;Foo::Bar&quot;)
</pre>
<p>should it return false? Or raise error &quot;Foo is not a class/module&quot;?</p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=352882013-01-09T02:31:29Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>I vote for false in both cases, like defined? operator.</p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=369112013-02-24T21:21:40Zko1 (Koichi Sasada)
<ul></ul><p>aaron, could you continue this discussion?</p>
Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=369122013-02-24T21:22:47Zko1 (Koichi Sasada)
<ul><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>2.1.0</i></li></ul> Ruby trunk - Feature #7414: Now that const_get supports "Foo::Bar" syntax, so should const_defined?.https://bugs.ruby-lang.org/issues/7414?journal_id=436592013-12-14T11:25:59Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset <a class="changeset" title="object.c: nested path const_defined? * object.c (rb_mod_const_defined): support nested class pat..." href="https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/44194">r44194</a>.<br>
Robert, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>object.c: nested path const_defined?</p>
<ul>
<li>object.c (rb_mod_const_defined): support nested class path as
well as const_get. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Now that const_get supports &quot;Foo::Bar&quot; syntax, so should const_defined?. (Closed)" href="https://bugs.ruby-lang.org/issues/7414">#7414</a>]</li>
</ul>