ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: andrew.kozin@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69704] [Ruby trunk - Bug #11294] [Open] Possible bug in Object.const_get
Date: Mon, 22 Jun 2015 21:23:45 +0000	[thread overview]
Message-ID: <redmine.issue-11294.20150622212345.9a76fc382ed81770@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11294.20150622212345@ruby-lang.org

Issue #11294 has been reported by Andrew Kozin.

----------------------------------------
Bug #11294: Possible bug in Object.const_get
https://bugs.ruby-lang.org/issues/11294

* Author: Andrew Kozin
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
~~~
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` to `Foo::Bar`, that is `Foo::Bar::Qux`, not the `Bar::Qux`

I cannot even understand the logic that follows the `Object.const_get` in providing such a result.



-- 
https://bugs.ruby-lang.org/

       reply	other threads:[~2015-06-22 21:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11294.20150622212345@ruby-lang.org>
2015-06-22 21:23 ` andrew.kozin [this message]
2015-06-22 23:21 ` [ruby-core:69707] [Ruby trunk - Bug #11294] [Rejected] Possible bug in Object.const_get nobu
2015-06-23 12:00 ` [ruby-core:69710] [Ruby trunk - Bug #11294] " andrew.kozin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-11294.20150622212345.9a76fc382ed81770@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).