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.0 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 AA8281F4C0 for ; Wed, 16 Oct 2019 07:06:30 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 57BB5120A46; Wed, 16 Oct 2019 16:06:21 +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 6E16D120A45 for ; Wed, 16 Oct 2019 16:06:19 +0900 (JST) Received: by filter0189p3mdw1.sendgrid.net with SMTP id filter0189p3mdw1-6519-5DA6C16C-2A 2019-10-16 07:06:20.325022297 +0000 UTC m=+550572.780317131 Received: from herokuapp.com (unknown [54.158.28.124]) by ismtpd0076p1mdw1.sendgrid.net (SG) with ESMTP id NxmvksBFR1GgLBHAT57k5A for ; Wed, 16 Oct 2019 07:06:20.248 +0000 (UTC) Date: Wed, 16 Oct 2019 07:06:20 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70944 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13249 X-Redmine-Issue-Author: abotalov X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: nobu 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?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4BxSMp2ka9LvyxKiI4EcwS?= =?us-ascii?Q?JpCHqMuiebSodVcjWgoPwdQMyv4urVZnzyJFRHs?= =?us-ascii?Q?rcCbuVNGNWxyBp9ndusgkg+kA7YefZ8caWi7CKL?= =?us-ascii?Q?d+sOt=2FaJU2qM9ozxhfiry19UM0PtuwkH3eil2Qn?= =?us-ascii?Q?udT7de5LYDAdMH6Vmt=2FZ8D3QdUWNj1YOS8A=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95356 Subject: [ruby-core:95356] [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 nobu (Nobuyoshi Nakada). * Is it necessary that check is placed inside the function `vm_cref_set_visibility`? What about calling a separate function where `check_method` flag is 1? * `rb_frame_callee` returns the called name, that may be an aliased name. Is it intentional? ---------------------------------------- Bug #13249: Access modifiers don't have an effect inside class methods in Ruby >= 2.3 https://bugs.ruby-lang.org/issues/13249#change-82064 * 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/