Actions
Bug #14704
closedModule#ancestors looks wrong when a module is both included and prepended in the same class.
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-04-20 trunk 63212) [x86_64-darwin17]
Tags:
Description
Module#ancestors
looks wrong when a module is both included and prepended in the same class.
Here is the example script:
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.
module M1; end
module M2; end
class Sub
include M1
include M2
end
# [Sub, M2, M1, Object, Kernel, BasicObject]
p Sub.ancestors
Actions
Like0
Like0Like0