From: knknkn1162@... Date: 2018-04-20T15:23:37+00:00 Subject: [ruby-core:86631] [Ruby trunk Bug#14704] Module#ancestors looks wrong when a module is both included and prepended in the same class. Issue #14704 has been reported by knknkn1162 (Kenta Nakajima). ---------------------------------------- Bug #14704: Module#ancestors looks wrong when a module is both included and prepended in the same class. https://bugs.ruby-lang.org/issues/14704 * Author: knknkn1162 (Kenta Nakajima) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.0dev (2018-04-20 trunk 63212) [x86_64-darwin17] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- `Module#ancestors` looks wrong when a module is both included and prepended in the same class. Here is the example script: ```ruby module M3; end module M1 include M3 end module M2 prepend M3 end class Sub include M1 include M2 end # [Sub, M1, M3, M2, Object, Kernel, BasicObject] p Sub.ancestors ``` The output is expected to be `[Sub, M2, M1, M3, Object, Kernel, BasicObject]` or `[Sub, M3, M2, M1, Object, Kernel, BasicObject]` or `[Sub, M3, M2, M1, M3, Object, Kernel, BasicObject]`, but the actual is `[Sub, M1, M3, M2, Object, Kernel, BasicObject]`. When the `M1` and `M2` module aren't included or prepended at all like the below script, the result is `[Sub, M2, M1, Object, Kernel, BasicObject]`. In the first example, the position of the `M2` module seems to be wrong. ```ruby module M1; end module M2; end class Sub include M1 include M2 end # [Sub, M2, M1, Object, Kernel, BasicObject] p Sub.ancestors ``` -- https://bugs.ruby-lang.org/ Unsubscribe: