From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 2F0091F4C0 for ; Thu, 17 Oct 2019 05:22:05 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id AAD9C120AAC; Thu, 17 Oct 2019 14:21:55 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8B081120A6D for ; Thu, 17 Oct 2019 14:21:53 +0900 (JST) Received: by filter0042p3iad2.sendgrid.net with SMTP id filter0042p3iad2-27846-5DA7FA72-28 2019-10-17 05:21:54.274123533 +0000 UTC m=+471291.423109946 Received: from herokuapp.com (unknown [54.158.28.124]) by ismtpd0038p1mdw1.sendgrid.net (SG) with ESMTP id NjqiJfvBSp6UPOwYRxDp4w for ; Thu, 17 Oct 2019 05:21:54.156 +0000 (UTC) Date: Thu, 17 Oct 2019 05:21:54 +0000 (UTC) From: matz@ruby.or.jp Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70968 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11055 X-Redmine-Issue-Author: nobu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: matz 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: =?us-ascii?Q?bXEIHGfdFwsIlBTndiToCp=2Fmc2rfxRD2sZAksRKJIHWOiJju51pNVZZA1OSw4G?= =?us-ascii?Q?RQNk4AMV4TKsbbv0JWQ9Ybl7fUr7=2FtV7h2IX8PC?= =?us-ascii?Q?7dzk+oj1patYUpo9TV2hnl7jdfZlEZqUUQp6lnt?= =?us-ascii?Q?QIy=2FHew2+ZiRSGU9qBC=2FqIHT0ogfAdf443+LbQc?= =?us-ascii?Q?h=2FLr6TaYnekhEchOgMtcAH2llm=2FhookhChQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95379 Subject: [ruby-core:95379] [Ruby master Bug#11055] autoload resets private_constant 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11055 has been updated by matz (Yukihiro Matsumoto). I agree with fixing this. Nobu will investigate the patch and consider the issue detail. Matz. ---------------------------------------- Bug #11055: autoload resets private_constant https://bugs.ruby-lang.org/issues/11055#change-82090 * Author: nobu (Nobuyoshi Nakada) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: * ruby -v: 50203 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Is this behavior intentional? Suppose the following file: ~~~ $ cat a/b.rb class A; B = 1; end ~~~ This causes `NameError`. ~~~ $ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; end' -e 'p A::B' -e:2:in `
': private constant A::B referenced (NameError) ~~~ But after it got loaded, `A::B` becomes public. ~~~ $ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; B; end' -e 'p A::B' 1 ~~~ ---Files-------------------------------- const-visibility-before-autoload-11055.patch (3.93 KB) -- https://bugs.ruby-lang.org/