--mimepart_4d3c7e00dcd55_1dc2ae129cc14643
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

Bug #4307: include fails after undef_method
http://redmine.ruby-lang.org/issues/show/4307

Author: Adriano Mitre
Status: Open, Priority: Normal
Category: core, Target version: 1.9.2
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]

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 method `foo' for [1]:Array
	from (irb):5
	from /home/adriano/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in `<main>'
>> Array.class_eval { include Foo }
=> Array
>> [1].foo
NoMethodError: undefined method `foo' for [1]:Array
	from (irb):7
	from /home/adriano/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in `<main>'

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.


----------------------------------------
http://redmine.ruby-lang.org

--mimepart_4d3c7e00dcd55_1dc2ae129cc14643
Content-Type: application/x-ruby; name=issue.rb
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=issue.rb

bW9kdWxlIEZvbzsgZGVmIGZvbzsgNDI7IGVuZDsgZW5kCkFycmF5LmNsYXNz
X2V2YWwgeyBpbmNsdWRlIEZvbyB9ClsxXS5mb28KQXJyYXkuY2xhc3NfZXZh
bCB7IEZvby5pbnN0YW5jZV9tZXRob2RzLmVhY2gge3xtfCBzZWxmLmNsYXNz
X2V2YWwgeyB1bmRlZl9tZXRob2QgbSB9IH0gfQpbMV0uZm9vCkFycmF5LmNs
YXNzX2V2YWwgeyBpbmNsdWRlIEZvbyB9ClsxXS5mb28KCg
--mimepart_4d3c7e00dcd55_1dc2ae129cc14643--