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=-2.8 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no 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 5C4F21F461 for ; Fri, 23 Aug 2019 23:06:56 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 704E1120B26; Sat, 24 Aug 2019 08:06:47 +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 355D9120B22 for ; Sat, 24 Aug 2019 08:06:45 +0900 (JST) Received: by filter0125p3las1.sendgrid.net with SMTP id filter0125p3las1-8958-5D607186-41 2019-08-23 23:06:46.973276722 +0000 UTC m=+536701.642765553 Received: from herokuapp.com (unknown [3.81.9.76]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id D2jN9PeQSFCesATdauaLRA for ; Fri, 23 Aug 2019 23:06:46.874 +0000 (UTC) Date: Fri, 23 Aug 2019 23:06:47 +0000 (UTC) From: shevegen@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70064 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16123 X-Redmine-Issue-Author: dylants X-Redmine-Sender: shevegen 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?6lbdtOg4RDRLuxD00eQtQKgoNAsge5d4xND7cbMQd0ypFhLCNe0EejvBzBiTpi?= =?us-ascii?Q?fHeh9fojswT1LIN0JZxJtWQ+6A1MeeuOTbav+zO?= =?us-ascii?Q?9RjMQ3QI=2F2hytVH90i0LGcv6+osyWAtM9iv4naH?= =?us-ascii?Q?nUa=2Fh+c6OBviMnHJliQqKduBDvQapAFUEMBS0C4?= =?us-ascii?Q?Y=2Fnc8PjolCxDKFIAJz9k=2FsvwNfUSXh8RH4g=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94515 Subject: [ruby-core:94515] [Ruby master Feature#16123] Allow calling a private method with `self.` 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 #16123 has been updated by shevegen (Robert A. Heiler). I may not completely understand the issue description. What is the inconsistency? (That is a honest question, by the way; I am not fully understanding the issue domain.) I am not even entirely sure what a private attribute writer is either; can we use these terms when we can use e. g. send() at all times? I may not understand this, but I assume you can get the value of any method via .send() and assign it to the local variable? ---------------------------------------- Feature #16123: Allow calling a private method with `self.` https://bugs.ruby-lang.org/issues/16123#change-80951 * Author: dylants (Dylan Thacker-Smith) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- ## Problem There is an inconsistency between calling a private attribute writer being allowed with `self.value =` syntax and `self.value` not being allowed on a private attribute writer. Calling a private method in this way can be useful when trying to assign the return value of this private method to a local variable with the same name. ## Solution The attached patch handles this by compiling the calling into a function call by using the `VM_CALL_FCALL` flag, so it is as if the call were made without the `self.` prefix, except it won't be confused with local variables at the VM instruction level. It is also compiled like an assignment call, except I didn't use the `COMPILE_RECV` macro, since that would remove the `CHECK` macro usage around the `COMPILE` line. ---Files-------------------------------- 0001-Allow-calling-a-private-method-with-self.diff.txt (3.28 KB) -- https://bugs.ruby-lang.org/