Project

General

Profile

Actions

Bug #17590

closed

`M.prepend M` has hidden side effect

Added by znz (Kazuhiro NISHIYAMA) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
[ruby-core:102283]

Description

M.prepend M raises ArgumentError, but it has hidden side effect.

module M; end
class C; end
C.prepend M
C.include M
M.prepend M rescue nil
module M2; end
M2.prepend M
C.include M2
p C.ancestors # => [M, C, M2, M, M2, Object, Kernel, BasicObject]
module M; end
class C; end
C.prepend M
C.include M
module M2; end
M2.prepend M
C.include M2
p C.ancestors # => [M, C, M2, Object, Kernel, BasicObject]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0