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 4C25D19C02B3 for ; Fri, 20 Nov 2015 18:14:28 +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 CCFF9B5D892 for ; Fri, 20 Nov 2015 18:45:20 +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 5C4AD18CC7AF for ; Fri, 20 Nov 2015 18:45:21 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4E833120456; Fri, 20 Nov 2015 18:45:20 +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 E556F120038 for ; Fri, 20 Nov 2015 18:45:15 +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=perWb3o5zbBpkbuOkZobHGMOPtc=; b=WebMohMOFEbzSTXTgB 6hYnK/ecn22Q3dAfr6Dsd2SoqthFRY7XE9gdkFpPhh/pXcNlZbF8KxzVQktDtds1 uBR8CwqC2wz3eJnL1mgxzP1TWREzbXbrpJ9KbZ1GcMbMGCkzfVxWmfqfIi/W16tE sAeGIqUNRn7e2j0Smhiwnva3Q= Received: by filter0422p1mdw1.sendgrid.net with SMTP id filter0422p1mdw1.4846.564EEBA521 2015-11-20 09:45:09.370152163 +0000 UTC Received: from herokuapp.com (ec2-50-17-29-76.compute-1.amazonaws.com [50.17.29.76]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id TMrqNbrOTRusvc7q_qNnyw for ; Fri, 20 Nov 2015 09:45:09.481 +0000 (UTC) Date: Fri, 20 Nov 2015 09:45:09 +0000 From: hanmac@gmx.de 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: 46273 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11718 X-Redmine-Issue-Author: vais X-Redmine-Sender: Hanmac 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4OU34miGeZpi9M4Zs5OYyRfx3OSrTlsWY3ij iPacjsAgbvM6s/yERpXQIK8dlD5uYrxm4vpNC6btwF9/0EdT+mnOGP6Y8i/ERW9urcwn+bPVTMdhfP v6cgvrZ43GmCIcX+ESk4+uMFq4PaaOpVScZl X-ML-Name: ruby-core X-Mail-Count: 71606 Subject: [ruby-core:71606] [Ruby trunk - Bug #11718] Constant access on `nil` 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 #11718 has been updated by Hans Mackowiak. yeah that should raise an error. A little test shows that this exist a while way back: ```ruby p nil::String ``` for 1.9.3: ```ruby String ``` for 1.8.7: ```ruby # is not a class/module (TypeError) ``` ---------------------------------------- Bug #11718: Constant access on `nil` https://bugs.ruby-lang.org/issues/11718#change-54990 * Author: Vais Salikhov * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- It is possible to access top-level constants by doing `nil::CONSTANT`, which looks like a bug [according to Matz](https://github.com/opal/opal/issues/1197#issuecomment-158078778). Here are a couple of examples: ``` $ ruby -ve "Foo = 123; p nil::Foo" ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 123 ``` ``` $ ruby -ve "class A; Foo = 456; end; p nil::A::Foo" ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 456 ``` Thanks! -- https://bugs.ruby-lang.org/