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 8DFA019C03C8 for ; Tue, 24 Nov 2015 08:54:21 +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 963A8B5DAAE for ; Mon, 23 Nov 2015 23:28:25 +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 4DE4A18CC7E3 for ; Mon, 23 Nov 2015 23:28:26 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4F4BE12044F; Mon, 23 Nov 2015 23:28:24 +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 05CE8120433 for ; Mon, 23 Nov 2015 23:28:19 +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=pg0pJw6ImnbC42j0eBx33uNk1sE=; b=ESX5EGI8QJGe4GcaQZ RtZv/9ANoaBtRHvjybxPM/zh56rpxE3ZMPUDLKH1G8QD1F+zgtLOG7/mstq/o2cr CpS++ZFj+j6BtDzgFwRFJcDDD1fM8SGwbiOMT3smJ8FPAL5ae5rUipxeWyYLTZen 53Mks8+gXT0lOsSPFxbtxXSTI= Received: by filter0118p1las1.sendgrid.net with SMTP id filter0118p1las1.1934.565321E645 2015-11-23 14:25:42.721963278 +0000 UTC Received: from herokuapp.com (ec2-54-81-199-226.compute-1.amazonaws.com [54.81.199.226]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id boL7UyaFTCOJKTZ5JYL2MA Mon, 23 Nov 2015 14:25:42.641 +0000 (UTC) Date: Mon, 23 Nov 2015 14:25:42 +0000 From: elia@schito.me To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Redmine-MailingListIntegration-Message-Ids: 46313 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11718 X-Redmine-Issue-Author: vais X-Redmine-Sender: elia 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS58nGw4xn1xJKlsw+b7nkQT96E9nZsZHmBn2E PXWy2ACGwNpY4xpfLhfTTD9jH0hcmkv4O84vfOafeE2g77ap9Umym6pC2/uNdmvn+nNekFzmrJPyo7 srZFiK+khpwO3NS2Fkzz4f3CQANDMDi9+XE8 X-ML-Name: ruby-core X-Mail-Count: 71640 Subject: [ruby-core:71640] [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 Elia Schito. looks like it's somehow intended behavior https://github.com/ruby/ruby/blob/trunk/insns.def#L179-L190 /** @c variable @e Get constant variable id. If klass is Qnil, constants are searched in the current scope. If klass is Qfalse, constants are searched as top level constants. Otherwise, get constant under= klass class or module. @j =E5=AE=9A=E6=95=B0 id =E3=81=AE=E5=80=A4=E3=82=92=E5=BE=97=E3=82= =8B=E3=80=82 klass =E3=81=8C Qnil =E3=81=AA=E3=82=89=E3=80=81=E3=81=9D=E3=81=AE= =E3=82=B9=E3=82=B3=E3=83=BC=E3=83=97=E3=81=A7=E5=BE=97=E3=82=89=E3=82=8C=E3= =82=8B=E5=AE=9A=E6=95=B0=E3=81=AE=E5=80=A4=E3=82=92=E5=BE=97=E3=82=8B=E3=80= =82 Qfalse =E3=81=AA=E3=82=89=E3=80=81=E3=83=88=E3=83=83=E3=83=97=E3= =83=AC=E3=83=99=E3=83=AB=E3=82=B9=E3=82=B3=E3=83=BC=E3=83=97=E3=82=92=E5=BE= =97=E3=82=8B=E3=80=82 =E3=81=9D=E3=82=8C=E4=BB=A5=E5=A4=96=E3=81=AA=E3=82=89=E3=80=81kla= ss =E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE=E4=B8=8B=E3=81=AE=E5=AE=9A=E6=95=B0= =E3=82=92=E5=BE=97=E3=82=8B=E3=80=82 */ apparently introduced here: https://github.com/ruby/ruby/commit/d84f9b16946= bca06ce0557ebe99152d7d445c9ec to resolve bug #10943 ---------------------------------------- Bug #11718: Constant access on `nil` https://bugs.ruby-lang.org/issues/11718#change-55042 * Author: Vais Salikhov * Status: Open * Priority: Normal * Assignee:=20 * 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`, whic= h 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 =3D 123; p nil::Foo" ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 123 ``` ``` $ ruby -ve "class A; Foo =3D 456; end; p nil::A::Foo" ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 456 ``` Thanks! --=20 https://bugs.ruby-lang.org/