Strange constant resolution behaviour after Class#dup

M

Martin Thiede

Hello,

the following code produces different results when executed with Ruby
1.8.6 on Windows and Fedora 9:

class A
def call_b_with_dup
B.dup.new.b
end
def call_b_without_dup
B.new.b
end
end

class B
def b
XXX
end
end

begin
A.new.call_b_with_dup
rescue Exception => e
puts e
end

begin
A.new.call_b_without_dup
rescue Exception => e
puts e
end

*** Results ***

Windows:

uninitialized constant B::XXX
uninitialized constant B::XXX

Fedora 9:

uninitialized constant A::XXX
uninitialized constant B::XXX


Whats the correct behaviour? I suppose the first one and the second is a
bug.
If so, is this bug already known?

Thanks,

Martin
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top