Project

General

Profile

Actions

Bug #10702

closed

Constant look up inconsistency with constants defined in included modules

Added by kwstannard (Kelly Stannard) about 9 years ago. Updated almost 9 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:67372]

Description

https://gist.github.com/kwstannard/c0f722976ba023cc5755

module A
  module B
  end
end

module C
  include A

  puts B.inspect # => A::B

  class D
    puts B.inspect rescue puts 'failed' # => failed
  end

  B = B

  class E
    puts B.inspect # => A::B
  end
end

When you include a module you gain access to that module's constants as seen in line 9. Line 19 shows that you can get constants defined in the nested module when the constant is defined within the module itself.

Line 12 is the bug. Shouldn't class D be able to access module B since the previous line shows that module C has access to Module B?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0