From: dylan.smith@shopify.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94511] [Ruby master Feature#16123] Allow calling a private method with `self.`
Date: Fri, 23 Aug 2019 21:03:32 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-16123.20190823210332.7b7003b9261dffd9@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16123.20190823210332@ruby-lang.org
Issue #16123 has been reported by dylants (Dylan Thacker-Smith).
----------------------------------------
Feature #16123: Allow calling a private method with `self.`
https://bugs.ruby-lang.org/issues/16123
* 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/
next parent reply other threads:[~2019-08-23 21:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16123.20190823210332@ruby-lang.org>
2019-08-23 21:03 ` dylan.smith [this message]
2019-08-23 23:06 ` [ruby-core:94515] [Ruby master Feature#16123] Allow calling a private method with `self.` shevegen
2019-08-24 0:30 ` [ruby-core:94518] " dylan.smith
2019-08-24 2:54 ` [ruby-core:94521] " sawadatsuyoshi
2019-09-18 8:01 ` [ruby-core:94953] " mame
2019-09-19 8:17 ` [ruby-core:94982] " matz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-16123.20190823210332.7b7003b9261dffd9@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).