Project

General

Profile

Actions

Bug #4795

closed

Nested classes don't seem to resolve correctly when another class exists with the same name

Bug #4795: Nested classes don't seem to resolve correctly when another class exists with the same name

Added by jxfruby (John Feminella) over 14 years ago. Updated over 14 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
Backport:
[ruby-core:36528]

Description

in /tmp/foo.rb

module Foo
end

module Foo::Bar
class Baz; end
end

class Baz
def say
"::Baz"
end
end

class Foo::Bar::Baz
def say
"::Foo::Bar::Baz"
end

def x
Baz.new.say
end
end

in irb:

load '/tmp/foo.rb'
=> true
Foo::Bar::Baz.new.x
=> "::Baz" # expected "::Foo::Bar::Baz"

=begin
This doesn't seem like the expected result. Have I misunderstood how constants work?
=end

Actions

Also available in: PDF Atom