Issue #4502 has been updated by Shyouhei Urabe.

Status changed from Open to Assigned
Assignee set to Koichi Sasada


----------------------------------------
Bug #4502: strange Module.new behaviour
http://redmine.ruby-lang.org/issues/4502

Author: Andy Bogdanov
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 
ruby -v: ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]


First I create a proc:
 p = proc {
   self::X = Class.new
   def self.X
     X.new
   end
 }
Then I create a module:
 A = Module.new(&p)
 puts A.X # => #<A::X:0x9c2e774>
Then I create another module:
 B = Module.new(&p)
 puts B.X # => #<B::X:0x9c39304>
Everything seems to be ok. But after module B was created (({A.X})) started to return instances of (({B::X}))
 puts A.X # => #<B::X:0x9c38238>

When (({self::X.new})) is used instead of (({X.new})) everything works as expected.

More info can be found here http://www.ruby-forum.com/topic/1275717


-- 
http://redmine.ruby-lang.org