ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:101618] [Ruby master Bug#17423] `Prepend` should prepend a module before the class
@ 2020-12-22  1:56 matz
  2020-12-22  2:33 ` [ruby-core:101620] " merch-redmine
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: matz @ 2020-12-22  1:56 UTC (permalink / raw)
  To: ruby-core

Issue #17423 has been reported by matz (Yukihiro Matsumoto).

----------------------------------------
Bug #17423: `Prepend` should prepend a module before the class
https://bugs.ruby-lang.org/issues/17423

* Author: matz (Yukihiro Matsumoto)
* Status: Open
* Priority: Normal
* Assignee: jeremyevans0 (Jeremy Evans)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I see

```ruby
module M; end
module A; end
class B; include A; end

A.prepend M
B.prepend M
p B.ancestors
```

gives `[B, M, A, Object, Kernel, BasicObject]` now. It used to be `[M, B, A, Object, Kernel, BasicObject]`.

I think it should be prepended to class `B`. Probably it should be `[M, B, M, A, Object, Kernel, BasicObject]`.

The reason behind this change may be duplication removing, but considering the following code, it is OK to duplicate prepende modules.

```ruby
module M; end
class A; end
class B<A; end

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

Am I missing something?

Matz.






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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-14 20:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22  1:56 [ruby-core:101618] [Ruby master Bug#17423] `Prepend` should prepend a module before the class matz
2020-12-22  2:33 ` [ruby-core:101620] " merch-redmine
2020-12-24  6:02 ` [ruby-core:101672] " matz
2021-01-14 20:48 ` [ruby-core:102097] " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).