# Method lookup weirdness

**URL:** <https://www.ruby-forum.com/t/method-lookup-weirdness/97626>\
**Category:** Ruby\
**Created:** [July 8, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/method-lookup-weirdness/97626 "2006-07-08T21:18:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [July 8, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/method-lookup-weirdness/97626/1 "2006-07-08T21:18:03Z")

</div>

Hi,

I’m a bit mystified by the following:

### Strange

module Foo  
extend self  
def bar; ‘bar’ end  
end

Foo.bar

module Foo  
remove\_method :bar  
end

Foo.bar

# =\> ‘bar’ # eh?

### Normal

module Bar  
extend self  
def foo; ‘foo’ end  
end

module Bar  
remove\_method :foo  
end

Bar.foo

# undefined method `foo’ for Bar:Module (NoMethodError)

### Broken

$ irb  
module Qux  
extend self  
def bar; ‘bar’ end  
end

Qux.bar

module Qux  
remove\_method :bar  
end

GC.start # eats Qux#bar ?

Qux.bar  
[BUG] terminated node (0x4057fdd8)  
ruby 1.8.4 (2005-12-24) [i486-linux]

The crash happens only in irb in my testing.

What might be causing this? If anyone with more  
knowledge of Ruby’s internals could shed  
light on this, I’d be grateful.
