From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 704921B80038 for ; Tue, 18 Apr 2017 12:59:03 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 53A65B5D95C for ; Tue, 18 Apr 2017 13:38:53 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id B4AE618CC81C for ; Tue, 18 Apr 2017 13:38:53 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C902D1207C5; Tue, 18 Apr 2017 13:38:52 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org 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 6E8DC1207BF for ; Tue, 18 Apr 2017 13:38:49 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=NHgNLLwlgOp/6/UwpMhX4KiONvw=; b=lwOi2niEcM+e5TZHu2 kYJpJDLxoShA3eo+s8lztPXHPyzFblNjHuyaKlakJiIs0BVwWObU7CFf1iBSg/Sv Jy9JAXuA9Fs13Mcjo+clhci/42oXYOL4hWzrkD2Dxi3+OLpksrimgj/ULl6BR+VO sU2Keaun+ohpke4khgtNGkmLk= Received: by filter0958p1mdw1.sendgrid.net with SMTP id filter0958p1mdw1-1015-58F59855-4D 2017-04-18 04:38:45.749836994 +0000 UTC Received: from herokuapp.com (ec2-54-80-44-125.compute-1.amazonaws.com [54.80.44.125]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id Lv0truSSTBa6rg7vMmSUaw Tue, 18 Apr 2017 04:38:45.699 +0000 (UTC) Date: Tue, 18 Apr 2017 04:38:45 +0000 From: shyouhei@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 55750 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13249 X-Redmine-Issue-Author: abotalov X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: shyouhei 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6eHCPD5YKaCPB8y1NKZJd9/ZSAfevxpzfISV FJnRpgpdlpbX+Lg9Xj8HVEd9uh0iRBjUQL+Kzf9wo4w11V69bz3LAo/yvsGu3P3HnhmSzFr8CezAye sXxugKJ6U/c2XkLyz1vpAZ1UIcYcLg265cHXFLD1NIZzUYtoFMXvYJx0gg== X-ML-Name: ruby-core X-Mail-Count: 80756 Subject: [ruby-core:80756] [Ruby trunk Bug#13249][Assigned] 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 shyouhei (Shyouhei Urabe). Status changed from Open to Assigned Assignee set to ko1 (Koichi Sasada) We looked at this issue in yesterday's developer meeting. The use of private in evolve75/RubyTree shown in the description is in fact wrong (methods are defined in a wrong place). That example made us think that the use of private in a method is a code smell. We would forbid such usage in a future. For the time being, let us show warning message. ---------------------------------------- Bug #13249: Access modifiers don't have an effect inside class methods in Ruby >= 2.3 https://bugs.ruby-lang.org/issues/13249#change-64312 * Author: abotalov (Andrei Botalov) * Status: Assigned * Priority: Normal * Assignee: ko1 (Koichi Sasada) * 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 ~~~ -- https://bugs.ruby-lang.org/