[ruby-core:96376] [Ruby master Bug#8841] Module#included_modules and prepended modules

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-83293.20191220143334.89f39d97f0d713a4@ruby-lang.org>
Issue #8841 has been updated by byroot (Jean Boussier).


> Module#included is not called when the module is prepended

I think that's fine, because it calls `Module#prepended`.

> Module#include? and Module#included_modules regard prepended modules as included (not well documented)

That yes:

```ruby
class Base
end

module A
end

module B
end

Base.prepend(A)
Base.include(B)

p Base.included_modules
```

outputs:

```
[A, B, Kernel]
```


----------------------------------------
Bug #8841: Module#included_modules and prepended modules
https://bugs.ruby-lang.org/issues/8841#change-83293

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: r42735
* Backport: 
----------------------------------------
The documentation for Module#included_modules currently states "Returns the list of modules included in +mod+."

This was never perfectly accurate, as the list also contains modules included in +mod+'s ancestors.

It now also includes prepended modules.

This is consistent with `include?` that returns true for prepended modules, but not quite consistent with `included` that does not get called for prepended modules.

Matz, could you confirm that current behavior is what you want?

If so, we should fix the documentation of `include?` and `included_modules`.



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.