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.8 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 1E3181F45A for ; Mon, 12 Aug 2019 04:02:09 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1C911120C66; Mon, 12 Aug 2019 13:02:02 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 2E81F120C5E for ; Mon, 12 Aug 2019 13:01:59 +0900 (JST) Received: by filter0009p3iad2.sendgrid.net with SMTP id filter0009p3iad2-26993-5D50E4B9-1A 2019-08-12 04:02:01.346051053 +0000 UTC m=+1415593.904923117 Received: from herokuapp.com (unknown [3.84.226.56]) by ismtpd0045p1mdw1.sendgrid.net (SG) with ESMTP id 7vUSsANkSrOCc2A77fiUpg for ; Mon, 12 Aug 2019 04:02:01.235 +0000 (UTC) Date: Mon, 12 Aug 2019 04:02:01 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69845 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11055 X-Redmine-Issue-Author: nobu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIoa5EKV2Z5wY7rwU=2Fk+uC=2Fx8ihlwb4fdfhGLSM?= =?us-ascii?Q?tX=2F49IiWaclfG9o4v3KG5p6DFuirG+TJLavLlKy?= =?us-ascii?Q?R36Ft5uyLpGmvdhlKm+wUYkwjp1AQGMVVCTqXM3?= =?us-ascii?Q?=2Fmn1G1SQ1Ob+d7xq+WTSKjONsFMlFdXfiPA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94299 Subject: [ruby-core:94299] [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 jeremyevans0 (Jeremy Evans). File const-visibility-before-autoload-11055.patch added I doubt dropping the existing constant visibility information is intentional behavior. You can work around the current behavior by resetting `private_constant`/`deprecate_constant` inside the autoloaded file, but that leads to duplication. Attached is a patch that will copy the constant visibility information across the autoload. ---------------------------------------- Bug #11055: autoload resets private_constant https://bugs.ruby-lang.org/issues/11055#change-80647 * 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/