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=-4.1 required=3.0 tests=AWL,BAYES_00, 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 3F7571F4C0 for ; Wed, 16 Oct 2019 05:27:04 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 95DD81209EB; Wed, 16 Oct 2019 14:26:54 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 6288F12099B for ; Wed, 16 Oct 2019 14:26:53 +0900 (JST) Received: by filter0082p3mdw1.sendgrid.net with SMTP id filter0082p3mdw1-23294-5DA6AA1E-4 2019-10-16 05:26:54.071723455 +0000 UTC m=+391595.832024036 Received: from herokuapp.com (unknown [3.84.173.95]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id JQfq73pfRUq3XndPBSOYOw for ; Wed, 16 Oct 2019 05:26:53.979 +0000 (UTC) Date: Wed, 16 Oct 2019 05:26:54 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70939 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13249 X-Redmine-Issue-Author: abotalov X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: mame 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?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb48pQKefhwuk1DE7gPuwYD?= =?us-ascii?Q?gdUasI9ZM9x13XaNy2+6Mt9TR2fkJ2vcAfa+j1I?= =?us-ascii?Q?07y2ymLDZiveFOZ7gSPXCBGSCVU=2F8TZri9WEFS9?= =?us-ascii?Q?f=2Fsp=2F1FYryu6QYd0ZtSr2VLtrMcsVi18ij6BtB+?= =?us-ascii?Q?QObUj6dvA2I6ggGbb8S64kBHSUKPSurCeSw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95351 Subject: [ruby-core:95351] [Ruby master Bug#13249] Access modifiers don't have an effect inside class methods in Ruby >= 2.3 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 #13249 has been updated by mame (Yusuke Endoh). Assignee changed from ko1 (Koichi Sasada) to nobu (Nobuyoshi Nakada) @nobu Could you review the patch? ---------------------------------------- Bug #13249: Access modifiers don't have an effect inside class methods in Ruby >= 2.3 https://bugs.ruby-lang.org/issues/13249#change-82059 * Author: abotalov (Andrei Botalov) * Status: Assigned * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * Target version: * ruby -v: 2.3.0, 2.4.0 * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Simple example: ~~~ ruby class C def self.foo private def bar end end end C.foo C.new.bar ~~~ This code runs fine on Ruby 2.3 and Ruby 2.4. It raises NoMethodError on Ruby 2.2 and prior versions. I would expect an error to be raised. Here is some code that actually uses private access modifier inside a class method - https://github.com/evolve75/RubyTree/blob/db48c35b0a3b96e4da473b095cc00e454d8a9996/lib/tree/utils/camel_case_method_handler.rb#L60 By the way, this code raises an error as expected on Ruby 2.3 and Ruby 2.4: ~~~ ruby class C def self.foo private def bar end end end C.foo C.new.bar # NoMethodError: private method `bar' called ~~~ ---Files-------------------------------- warn-scope-visibility-in-method-13249.patch (4.18 KB) -- https://bugs.ruby-lang.org/