From: Jeremy Kemper Date: 2009-06-07T10:18:13+09:00 Subject: [ruby-core:23740] [Bug #1586] Including a module already present in ancestors should not be ignored Bug #1586: Including a module already present in ancestors should not be ignored http://redmine.ruby-lang.org/issues/show/1586 Author: Jeremy Kemper Status: Open, Priority: Normal ruby -v: ruby 1.8.8dev (2009-03-19 revision 23009) [i386-darwin9.6.2] The scenario: * I include Foo in Numeric to provide #bar * Some other library includes a module in Float to provide #bar * So I include Foo in Float to use my #bar * But including Foo in Float is ignored since it's already in the ancestor chain I think it should be added to the ancestor chain, even if it's already present, since I may want to override some other method earlier in the ancestor chain. # Including a module already included in a superclass is ignored >> module Foo; end => nil >> class Numeric; include Foo; end => Numeric >> Float.ancestors => [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] >> class Float; include Foo; end => Float >> Float.ancestors => [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] # Reversing the order of inclusion works as expected >> module Foo; end => nil >> class Float; include Foo; end => Float >> Float.ancestors => [Float, Foo, Precision, Numeric, Comparable, Object, Kernel] >> class Numeric; include Foo; end => Numeric >> Float.ancestors => [Float, Foo, Precision, Numeric, Foo, Comparable, Object, Kernel] # And so does including a dupe of the existing module in the subclass >> module Foo; end => nil >> class Numeric; include Foo; end => Numeric >> Float.ancestors => [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] >> class Float; include Foo.dup; end => Float >> Float.ancestors => [Float, #, Precision, Numeric, Foo, Comparable, Object, Kernel] ---------------------------------------- http://redmine.ruby-lang.org