From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id A51D91960007 for ; Tue, 23 Jun 2015 20:37:07 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id AF6B9B5D967 for ; Tue, 23 Jun 2015 21:00:56 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 2BDDE97A836 for ; Tue, 23 Jun 2015 21:00:59 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q8lFUFuF9Xz7 for ; Tue, 23 Jun 2015 21:00:59 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E323597A826 for ; Tue, 23 Jun 2015 21:00:58 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 3DC8695243A for ; Tue, 23 Jun 2015 21:00:56 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D061F12044A; Tue, 23 Jun 2015 21:00:54 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9829A120420 for ; Tue, 23 Jun 2015 21:00:51 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=p+Dte8EAGpj6/WLNy0eqC7PjZDk=; b=oUvTU/Lh9aLrRYW93T xCDc9XHXKqlGhJdzDl5PtCoU2DG4mURF/ky2VUESvohfwS/Lld5q0koh+B365QMT wn6dElhWRSn9K9TR//sz3nO/aNGfWZ0o2QlggL0ufMiq4/h6MEbm24u4a9DEHgGL YzvfNJwgsv/Tqk3q6eaBs2Oe4= Received: by filter0631p1mdw1.sendgrid.net with SMTP id filter0631p1mdw1.10795.55894A6B57 2015-06-23 12:00:43.650804753 +0000 UTC Received: from herokuapp.com (ec2-54-91-14-84.compute-1.amazonaws.com [54.91.14.84]) by ismtpd-050 (SG) with ESMTP id 14e204ab3a7.10e6.43b5e5 for ; Tue, 23 Jun 2015 12:00:43 +0000 (UTC) Date: Tue, 23 Jun 2015 12:00:43 +0000 From: andrew.kozin@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44274 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11294 X-Redmine-Issue-Author: nepalez X-Redmine-Sender: nepalez X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4fX33IwabpZ1IOH3aeWwfVcpi1XSaOq0qwCG JDQ3t3Szjgg1gYBRfyvFPI/zKc2F1Z3zdESm84ByuelKGjOg0SwkWnAzgm/JBq2DeNKEYxyTWN69ao xdbxWXu0ihdoQlv2eV5WzYYA/UX2e6qIhCxL X-ML-Name: ruby-core X-Mail-Count: 69710 Subject: [ruby-core:69710] [Ruby trunk - Bug #11294] Possible bug in Object.const_get X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11294 has been updated by Andrew Kozin. Thank you, Nobuyoshi, for your answering. Now I see the reason, but IMHO this behaviour is a bit perplexing. I think it still be useful to have a "strict" version of `Object.get_const` that would treat the namespace literally with a syntax of sorts: ~~~ Object.get_const "Foo::Baz::Bar::Qux", strict: true # => NameError: uninitialized constant Foo::Baz::Bar ~~~ ---------------------------------------- Bug #11294: Possible bug in Object.const_get https://bugs.ruby-lang.org/issues/11294#change-53088 * Author: Andrew Kozin * Status: Rejected * Priority: Normal * Assignee: * ruby -v: 2.2 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ~~~ruby 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`: ~~~ruby module Foo::Bar; end module Foo::Bar::Qux; end ~~~ then the tree becomes as following: ~~~ruby Foo::Bar::Qux Foo::Baz Bar::Qux ~~~ But the result remains the same: ~~~ruby 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/