Bug #4307
closedinclude fails after undef_method
Description
=begin
After using #undef_method on a method "inherited" from a mixin, reincluding the mixin should redefine it, but that is not what happens.
Please take a look at this short IRB transcript (source attached):
module Foo; def foo; 42; end; end
=> nil
Array.class_eval { include Foo }
=> Array
[1].foo
=> 42
Array.class_eval { Foo.instance_methods.each {|m| self.class_eval { undef_method m } } }
=> [:foo]
[1].foo
NoMethodError: undefined methodfoo' for [1]:Array from (irb):5 from /home/adriano/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in
'
Array.class_eval { include Foo }
=> Array
[1].foo
NoMethodError: undefined methodfoo' for [1]:Array from (irb):7 from /home/adriano/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in
'
The last command should just return 42, instead of raising a NoMethodError exception.
Note that this also applies to the following Ruby implementations:
- ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
- rbx-1.2.0-20101221 [ ]
- jruby-1.5.6 [ amd64-java
Thus, it may be a language specification gap, not just an implementation bug.
=end
Files