Issue #2740 has been updated by Yehuda Katz.


Upon further reflection, I really like the idea of raising an exception like NoConstantError from const_missing to tell Ruby to keep searching up the nesting chain.

    class Module
      def const_missing(name)
        puts "#{self} is missing #{name}"
        raise NoConstantError unless self == Object
      end
    end

    module Foo
      module Bar
        Baz
      end
    end

    # Output:
    # Foo::Bar is missing Baz
    # Foo is missing Baz
    # Object is missing Baz

    module Foo::Bar
      Baz
    end

    # Output
    # Foo::Bar is missing Baz
    # Object is missing Baz

    module Foo::Bar
      Foo::Bar::Baz
    end

    # Output
    # Foo::Bar is missing Baz

    module Foo
      Bar::Baz
    end

    # Output
    # Foo::Bar is missing Baz

Thoughts?
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2740

----------------------------------------
http://redmine.ruby-lang.org