From: Koichi Sasada Date: 2012-03-11T17:43:11+09:00 Subject: [ruby-core:43222] [ruby-trunk - Bug #6078] The name of a module nested in an anonymous module depends on how it was created Issue #6078 has been updated by Koichi Sasada. Assignee set to Nobuyoshi Nakada ---------------------------------------- Bug #6078: The name of a module nested in an anonymous module depends on how it was created https://bugs.ruby-lang.org/issues/6078 Author: Brian Ford Status: Open Priority: Normal Assignee: Nobuyoshi Nakada Category: Target version: ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0] If a module is nested under an anonymous module, the nested modules name will depend on how the module is created. See below: $ irb 1.9.3p125 :001 > m = Module.new => # 1.9.3p125 :002 > n = Module.new => # 1.9.3p125 :003 > m::N = n => # 1.9.3p125 :004 > m.name => nil 1.9.3p125 :005 > n.name => nil 1.9.3p125 :006 > m.constants => [:N] 1.9.3p125 :007 > module m::O 1.9.3p125 :008?> end => nil 1.9.3p125 :009 > m.constants => [:N, :O] 1.9.3p125 :010 > m::N.name => nil 1.9.3p125 :011 > m::O.name => "#::O" 1.9.3p125 :012 > m.const_get(:N).name => nil 1.9.3p125 :013 > m.const_get(:O).name => "#::O" 1.9.3p125 :014 > M = m => M 1.9.3p125 :015 > m::N.name => "M::N" 1.9.3p125 :016 > m::O.name => "#::O" Thanks, Brian -- http://bugs.ruby-lang.org/