From: "tarui (Masaya Tarui)" Date: 2012-12-13T06:29:11+09:00 Subject: [ruby-core:50841] [ruby-trunk - Bug #7107] Ruby can no longer find constants in methods in anonymous modules Issue #7107 has been updated by tarui (Masaya Tarui). additional sample. d.f referring to M::C is correct? or d::C? $ ruby -e "module M;C=1;def self.f;C end end;d=M.dup;p M.f;p d.f;d::C=2;p M.f;p d::C;p d.f" 1 1 -e:1: warning: already initialized constant #::C -e:1: warning: previous definition of C was here 1 2 1 ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107#change-34676 Author: drbrain (Eric Hodel) Status: Assigned Priority: Normal Assignee: nobu (Nobuyoshi Nakada) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-09-06 trunk 36915) [x86_64-darwin12.1.0] =begin With ruby 1.9 and newer C cannot be found if m is duplicated: module M C = 1 def self.m C end end puts 'named module' M.m puts 'anonymous module' m = M.dup m.m Ruby 1.8: $ ruby -v t.rb ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0] named module anonymous module With Ruby 1.9: $ ruby19 -v t.rb ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] named module anonymous module t.rb:5:in `m': uninitialized constant Module::C (NameError) from t.rb:14:in `
' With trunk: $ ruby19 -v t.rb ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] named module anonymous module t.rb:5:in `m': uninitialized constant Module::C (NameError) from t.rb:14:in `
' (({m::C})) works in all three versions, though. =end -- http://bugs.ruby-lang.org/