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 9ACBA19C02B3 for ; Fri, 20 Nov 2015 17:48:00 +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 0D85FB5D8DE for ; Fri, 20 Nov 2015 18:18:53 +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 8DCFC18CC7EB for ; Fri, 20 Nov 2015 18:18:53 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A9EED120457; Fri, 20 Nov 2015 18:18:51 +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 173C812043A for ; Fri, 20 Nov 2015 18:18:47 +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=32LDub6kdRi2V1Y+9KqRrKh3N7I=; b=gbOoTfhVOFkOVhhUmg JhPrWaYWNDOnRNkii8cMszY4aJ35UgTArAAZzuM2OkR7cwEuyR0Z/9aiGckSoMHx K5XxwPpBkGu/cR285C7QLqhhOkOfPgdgYxrxzMVcyAdO1XbLviuZV8y8cJkh1Zta 8wCZqyUrMatrUPXmXBfv8Ebcs= Received: by filter0886p1mdw1.sendgrid.net with SMTP id filter0886p1mdw1.31678.564EE57520 2015-11-20 09:18:45.316280827 +0000 UTC Received: from herokuapp.com (ec2-54-145-73-201.compute-1.amazonaws.com [54.145.73.201]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id mpsqBmxpQIWnCcQ587JYrQ for ; Fri, 20 Nov 2015 09:18:45.400 +0000 (UTC) Date: Fri, 20 Nov 2015 09:18:45 +0000 From: eregontp@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: 46272 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11718 X-Redmine-Issue-Author: vais X-Redmine-Sender: Eregon 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4J656a7wQrBpSlCiB1VWmwyqJi1XwaIcPvZ5 u4hmDbEnpsuS2qQdPnWpp5hmf55bu46VSL7wGM3AkxsOfFWXKbOcOUZd9adBuwD345k3XC4n3om4eP HPlsIptNY9HqrM3O5IjPM32Ab3qnRE/p4gZh X-SendGrid-Contentd-ID: {"test_id":"1448011125"} X-ML-Name: ruby-core X-Mail-Count: 71605 Subject: [ruby-core:71605] [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 Benoit Daloze. I think this should really raise an error like: $ ruby -e 'p nil::String' -e:1:in `
': nil is not a class/module (TypeError) ---------------------------------------- Bug #11718: Constant access on `nil` https://bugs.ruby-lang.org/issues/11718#change-54989 * 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/