Actions
Bug #11294
closedPossible bug in Object.const_get
Description
module Foo; end
module Foo::Baz; end
module Bar; end
module Bar::Qux; end
Object.const_get "Foo::Baz::Bar::Qux"
# => Bar::Qux
Why on earth it is found at all?
It seems pretty weird to me.
The real problem arises later, when I add Foo::Bar::Qux
:
module Foo::Bar; end
module Foo::Bar::Qux; end
then the tree becomes as following:
Foo::Bar::Qux
Foo::Baz
Bar::Qux
But the result remains the same:
Object.const_get "Foo::Baz::Bar::Qux"
# => Bar::Qux
Here I'd expect searching "Foo::Baz::Bar::Qux"
to
- either return nothing (this is less astonished, because there is no such constant),
- or find the closest
Bar::Qux
toFoo::Bar
, that isFoo::Bar::Qux
, not theBar::Qux
I cannot even understand the logic that follows the Object.const_get
in providing such a result.
Actions
Like0
Like0Like0