https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112014-09-16T18:32:23ZRuby Issue Tracking SystemRuby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=489332014-09-16T18:32:23Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>A couple questions:</p>
<ol>
<li>Which of the two cases tested is unexpected (or is it both)? The two cases are (in pseudo-spec-ese):</li>
</ol>
<ul>
<li>If a module A has been included into class B, and then additional modules are included into A, calls to B <em>will not</em> see them without a re-include of A.</li>
<li>If a module A has been inlcluded into class B, and then methods are modified in A, calls to B <em>will</em> see them without a re-include of A.</li>
</ul>
<p>Ignore the mentions of "flushing" in the spec...the above behavior is what it really tests.</p>
<p>It works this way because at include time, a <em>reference</em> to the module is inserted into the target hierarchy, and <em>only</em> its method table gets searched; other modules that the first module includes are themselves <em>included</em> into the hierarchy.</p>
<p>Included modules are only searched for methods and constants they directly define. The module's method and constant tables are virtually proxied into the target hierarchy, but the module's superclasses are only included at include time.</p>
<p>I don't know why this is the case.</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=489342014-09-16T18:39:42ZEregon (Benoit Daloze)
<ul></ul><p>Module#ancestors is still respected for which modules to look up so it is somewhat consistent, but rather confusing indeed.<br>
Including a module in a class computes the module ancestors when it is included, and further (module) transitive inclusions are therefore not considered.<br>
But re-including the module works in this case as the last line shows.<br>
I do not know the reason of this but it very likely is spec.</p>
<pre><code>> class A; end
> module B; end
> class C < A; include B; end
> module X; end
> module B; include X; end
> B.ancestors
=> [B, X]
> C.ancestors
=> [C, B, A, Object, Kernel, BasicObject]
> class D < A; include B; end
> D.ancestors
=> [D, B, X, A, Object, Kernel, BasicObject]
> class C < A; include B; end
> C.ancestors
=> [C, B, X, A, Object, Kernel, BasicObject]
</code></pre> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=489392014-09-17T02:17:04Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>It's a TODO, which should be fixed in the future, and there are some related tickets.</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=489402014-09-17T02:30:51Ztduehr (Timur Duehr)tduehr@gmail.com
<ul></ul><p>Nobuyoshi Nakada wrote:</p>
<blockquote>
<p>It's a TODO, which should be fixed in the future, and there are some related tickets.</p>
</blockquote>
<p>Is that to change the behavior or add the tests?</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=489412014-09-17T02:33:47Ztduehr (Timur Duehr)tduehr@gmail.com
<ul></ul><p>Ahh... just found it. <a href="https://bugs.ruby-lang.org/issues/9112" class="external">https://bugs.ruby-lang.org/issues/9112</a></p>
<p>Thanks</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=492992014-10-08T16:16:49Ztduehr (Timur Duehr)tduehr@gmail.com
<ul></ul><p>I've created a patch to the MRI test suite used in JRuby to check for this behavior.</p>
<p><a href="https://github.com/tduehr/jruby/commit/5bf0da4e4fff1a9e122ff427ff34586025db9955" class="external">https://github.com/tduehr/jruby/commit/5bf0da4e4fff1a9e122ff427ff34586025db9955</a></p>
<p>I'm now using <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Make module lookup more dynamic (Including modules into a module after it has already been included) (Closed)" href="https://redmine.ruby-lang.org/issues/9112">#9112</a> for discussion on new behavior with a patch to hopefully come before too long.</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=498032014-11-05T05:06:41Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>Perhaps we can incorporate the tests now, if it's considered spec behavior? If it is not considered spec behavior, then this is a little fuzzy to me. I'd like to have clarification one way or the other.</p>
<p>I can commit the tests if approved.</p> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=689242017-12-25T18:15:13Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.6</i></del>)</li></ul> Ruby master - Bug #10248: Possible missing test or bug for Module#include and Module#prependhttps://redmine.ruby-lang.org/issues/10248?journal_id=868492020-07-30T18:52:38Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>