Method lookup weirdness

  • Thread starter Ilmari Heikkinen
  • Start date
I

Ilmari Heikkinen

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.
 
T

ts

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 ?
 
I

Ilmari Heikkinen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top