Method lookup weirdness

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.

“I” == Ilmari H. [email protected] writes:

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

It’s a bug : can you submit it to ruby-bug ?

Guy Decoux

On 7/9/06, ts [email protected] wrote:

“I” == Ilmari H. [email protected] writes:

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

It’s a bug : can you submit it to ruby-bug ?

Ok, thanks. Done.