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 09B1919E005C for ; Fri, 18 Dec 2015 16:58:49 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 20257B5D916 for ; Fri, 18 Dec 2015 17:30:56 +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 8B57F18CC7B8 for ; Fri, 18 Dec 2015 17:30:56 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4ECC1120667; Fri, 18 Dec 2015 17:30:54 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 095301205F7 for ; Fri, 18 Dec 2015 17:30:49 +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=ZdfFTexZQIjL+K4CooH1xMf+Y1A=; b=H5yqO9wYGmQsyGyobX 1jeuDuZ5i6GDd+v5dHDghZcwDhQRx0358oAsNdyOmHVkRwuoi2ygkxT83Ke6OyJP OZI2ZrheoeMM421b4kN/Gw99ihNJcd218/dOKxgFBoxHUaIhlKoXBqsreb/SEiAt +WmK/jiuFCdO2xuKrRrE4/Yxg= Received: by filter0602p1mdw1.sendgrid.net with SMTP id filter0602p1mdw1.21845.5673C4331A 2015-12-18 08:30:43.500080195 +0000 UTC Received: from herokuapp.com (ec2-54-242-87-41.compute-1.amazonaws.com [54.242.87.41]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id x_963zOoReS8-4q4t6ePvg for ; Fri, 18 Dec 2015 08:30:43.508 +0000 (UTC) Date: Fri, 18 Dec 2015 08:30:43 +0000 From: shugo@ruby-lang.org 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: 46954 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11705 X-Redmine-Issue-Author: mwpastore X-Redmine-Sender: shugo 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5yHQ1t1/qrivu/KbJGj68E3ULVXAaS1WnMUj 0GTpBeAsPNrftMS8sJKiQqOTvmkl86o9Zc70C45b1ioAe8WQfA9PyZKKZgDE1ix+l9mn9i/TXtCkul h1DhzW925geTJ2xMoEjf5Nbdi04dywpJZdCkBqOXx7eClEAFzShawNdSmA== X-SendGrid-Contentd-ID: {"test_id":"1450427445"} X-ML-Name: ruby-core X-Mail-Count: 72359 Subject: [ruby-core:72359] [Ruby trunk - Bug #11705] [Rejected] Namespace resolution in nested modules with short syntax 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 #11705 has been updated by Shugo Maeda. Status changed from Open to Rejected Mike Pastore wrote: > Is this intentional and/or expected? It's intentional and expected. If class and/or module definitions are explicitly nested, constants of outer classes and/or modules are looked up. However, if a class or module definition is not nested, only constants in the class or module, its ancestors, and if the target is a module, `Object` and `Object`'s ancestors are looked up. You can see module nesting information by `Module.nesting`. ``` module Foo module Bar p Module.nesting #=> [Foo::Bar, Foo] p Qux.hello #=> "Hello, world!" end end module Foo::Bar p Module.nesting #=> [Foo::Bar] p Qux.hello #=> NameError, because Foo is not included in Module.nesting end ``` ---------------------------------------- Bug #11705: Namespace resolution in nested modules with short syntax https://bugs.ruby-lang.org/issues/11705#change-55652 * Author: Mike Pastore * Status: Rejected * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Given the following definition: ~~~ module Foo class Qux def self.hello 'Hello, world!' end end end ~~~ Namespace resolution at a later time works differently when you have nested modules, e.g. ~~~ module Foo module Bar # Can't find Foo::Bar::Qux, so "goes up" to find Foo::Qux. p Qux.hello # < "Hello, world!" end end ~~~ vs. the short syntax, e.g. ~~~ module Foo::Bar # Can't find Foo::Bar::Qux, but doesn't "go up" to find Foo::Qux. p Qux.hello # < in `': uninitialized constant Foo::Bar::Qux (NameError) end ~~~ Is this intentional and/or expected? -- https://bugs.ruby-lang.org/