Project

General

Profile

Bug #14704

Module#ancestors looks wrong when a module is both included and prepended in the same class.

Added by knknkn1162 (Kenta Nakajima) over 1 year ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-04-20 trunk 63212) [x86_64-darwin17]
[ruby-core:86631]

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

Related issues

Related to Ruby master - Bug #7844: include/prepend satisfiable module dependencies are not satisfiedAssignedActions

History

#1

Updated by jeremyevans0 (Jeremy Evans) about 2 months ago

  • Related to Bug #7844: include/prepend satisfiable module dependencies are not satisfied added

Also available in: Atom PDF