Project

General

Profile

Actions

Bug #4307

closed

include fails after undef_method

Added by adrianomitre (Adriano Mitre) almost 14 years ago. Updated over 12 years ago.

Status:
Rejected
Target version:
ruby -v:
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
Backport:
[ruby-core:34806]

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 method foo' 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 method foo' 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

issue.rb (214 Bytes) issue.rb adrianomitre (Adriano Mitre), 01/24/2011 04:14 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0