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 3382E1F4C0 for ; Wed, 16 Oct 2019 19:10:28 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8830D120A4F; Thu, 17 Oct 2019 04:10:17 +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 94800120A26 for ; Thu, 17 Oct 2019 04:10:14 +0900 (JST) Received: by filter0083p3mdw1.sendgrid.net with SMTP id filter0083p3mdw1-21442-5DA76B19-1 2019-10-16 19:10:17.043111316 +0000 UTC m=+440997.616036992 Received: from herokuapp.com (unknown [54.158.28.124]) by ismtpd0065p1iad2.sendgrid.net (SG) with ESMTP id MLAlY8h0T2KsTGpqfRV0cQ for ; Wed, 16 Oct 2019 19:10:17.065 +0000 (UTC) Date: Wed, 16 Oct 2019 19:10:17 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70960 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13249 X-Redmine-Issue-Author: abotalov X-Redmine-Issue-Assignee: nobu 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?BItn1A33AadvD=2FYhs5tM7e9Q15yjicxt9cQQX4o?= =?us-ascii?Q?Q+3f0K9DPX4JRmy=2FsI4LgMHgT1D04081nfCB6aI?= =?us-ascii?Q?Bzk2tFuQKwQArXeQewL3Tj98YBtukf3x3wZ3irj?= =?us-ascii?Q?AlZn3sqPBjC4ukNCm=2Fq9AMX15MXzwwyGcIA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95372 Subject: [ruby-core:95372] [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 jeremyevans0 (Jeremy Evans). nobu (Nobuyoshi Nakada) wrote: > * 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? I agree, that makes more sense. > * `rb_frame_callee` returns the called name, that may be an aliased name. > Is it intentional? No. It would be better to use `rb_frame_this_func` instead, I think. Thank you very much for your review. I've added the modified patch as a pull request (https://github.com/ruby/ruby/pull/2562). Assuming it passes CI, I will merge it. ---------------------------------------- Bug #13249: Access modifiers don't have an effect inside class methods in Ruby >= 2.3 https://bugs.ruby-lang.org/issues/13249#change-82080 * 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/