# Strange constant resolution behaviour after Class#dup

**URL:** <https://www.ruby-forum.com/t/strange-constant-resolution-behaviour-after-class-dup/160339>\
**Category:** Ruby\
**Created:** [February 14, 2009, 10:08pm UTC](https://www.ruby-forum.com/t/strange-constant-resolution-behaviour-after-class-dup/160339 "2009-02-14T22:08:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mthomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/278dde/32.png) [@mthomas](https://www.ruby-forum.com/u/mthomas)\
**Post date:** [February 14, 2009, 10:08pm UTC](https://www.ruby-forum.com/t/strange-constant-resolution-behaviour-after-class-dup/160339/1 "2009-02-14T22:08:49Z")

</div>

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
