Issue #7107 has been reported by drbrain (Eric Hodel). ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107 Author: drbrain (Eric Hodel) Status: Open Priority: Normal Assignee: 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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
on 2012-10-05 03:07
on 2012-10-05 22:48
Issue #7107 has been updated by drbrain (Eric Hodel).
=begin
Additionally, when the module is given a name it still can't find the
constant:
module M
C = 1
def self.m
C
end
end
puts 'named module'
M.m
puts 'anonymous module'
m = M.dup
begin
m.m
rescue NameError
p $!
end
puts 're-named module'
N = m
begin
N.m
rescue NameError
p $!
end
Ruby trunk:
$ ruby20 -v t.rb
ruby 2.0.0dev (2012-09-06 trunk 36915) [x86_64-darwin12.1.0]
named module
anonymous module
#<NameError: uninitialized constant Module::C>
re-named module
#<NameError: uninitialized constant Module::C>
=end
----------------------------------------
Bug #7107: Ruby can no longer find constants in methods in anonymous
modules
https://bugs.ruby-lang.org/issues/7107#change-30113
Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee:
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 `<main>'
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 `<main>'
(({m::C})) works in all three versions, though.
=end
on 2012-10-27 02:41
Issue #7107 has been updated by ko1 (Koichi Sasada). Assignee set to mame (Yusuke Endoh) ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107#change-31732 Author: drbrain (Eric Hodel) Status: Open Priority: Normal Assignee: mame (Yusuke Endoh) 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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
[ruby-trunk - Bug #7107][Assigned] Ruby can no longer find constants in methods in anonymous modules
on 2012-10-27 12:09
Issue #7107 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee changed from mame (Yusuke Endoh) to nobu (Nobuyoshi Nakada) Indeed, it looks a bug. Nobu, could you investigate? -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107#change-31788 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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
on 2012-12-12 21:55
Issue #7107 has been updated by tarui (Masaya Tarui).
hi,
I found strange behavior.
$ ruby -e "module M;C=1;def self.f;C end end;d=M.dup;p M.f;p d.f;class
A;end;p d.f"
1
1
-e:1:in `f': uninitialized constant Module::C (NameError)
from -e:1:in `<main>'
It seems to hold the problem in InlineCache too.
----------------------------------------
Bug #7107: Ruby can no longer find constants in methods in anonymous
modules
https://bugs.ruby-lang.org/issues/7107#change-34675
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 `<main>'
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 `<main>'
(({m::C})) works in all three versions, though.
=end
on 2012-12-12 22:29
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 #<Module:0x007ffb39f4c860>::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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
on 2012-12-15 04:26
Issue #7107 has been updated by charliesome (Charlie Somerville). =begin Nobu, I have found the cause of the bug - the cref_stack of methods are not fixed up to point to the new class/module when the class/module is duped. Do you want me to commit it or attach it here for your review? =end ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107#change-34758 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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
on 2012-12-17 03:40
Issue #7107 has been updated by charliesome (Charlie Somerville). Assignee changed from nobu (Nobuyoshi Nakada) to charliesome (Charlie Somerville) ---------------------------------------- Bug #7107: Ruby can no longer find constants in methods in anonymous modules https://bugs.ruby-lang.org/issues/7107#change-34786 Author: drbrain (Eric Hodel) Status: Assigned Priority: Normal Assignee: charliesome (Charlie Somerville) 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 `<main>' 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 `<main>' (({m::C})) works in all three versions, though. =end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.