[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Method lookup weirdness

Ilmari Heikkinen

7/8/2006 7:16:00 PM

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.


--
ilmari

2 Answers

ts

7/9/2006 10:04:00 AM

0

>>>>> "I" == Ilmari Heikkinen <ilmari.heikkinen@gmail.com> 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

Ilmari Heikkinen

7/9/2006 1:21:00 PM

0

On 7/9/06, ts <decoux@moulon.inra.fr> wrote:
> >>>>> "I" == Ilmari Heikkinen <ilmari.heikkinen@gmail.com> 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.

--
Ilmari