Issue #12834 has been updated by shyouhei (Shyouhei Urabe).


We looked at this issue in yesterday's developer meeting.

While discussing, we learned that prepended ancestors are not linearizable using the C3 algorithm.  When you prepend something, you normally want to override a method in a specific order.  So a prepending module and its prepended counterpart must be adjacent in a superclass resolution.  Thus, matz started thinking that if a module is prepended multiple times, that should appear more than once in a method chain.

----------------------------------------
Bug #12834: `prepend` getting prepended even if it already exists in the ancestors chain
https://bugs.ruby-lang.org/issues/12834#change-64313

* Author: ndn (Nikola Nenkov)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.3.1
* Backport: 2.3: UNKNOWN
----------------------------------------
```
module M; end
class A; prepend M; end
class B < A; prepend M; end

B.ancestors # => [M, B, M, A, Object, Kernel, BasicObject]
```

Even though I find this behaviour to be more intuitive, it is inconsistent with `Module#include` and is potentially breaking.
I didn't see a mention on the [[release notes]](https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/) and the [[documentation]](https://ruby-doc.org/core-2.3.1/Module.html#method-i-prepend_features) is now outdated. 



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>