diff options
author | Dylan Thacker-Smith <Dylan.Smith@shopify.com> | 2019-07-02 15:06:54 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-20 02:20:59 +0900 |
commit | 7fbd2f7cc247ee66e877ab3c88f0274834c6b6c7 (patch) | |
tree | 1d03cfc0cba9aabb542306f7f1f685dfb636f0c1 /compile.c | |
parent | 17a13663998a98ff75fcc838d1cea95c879fbb88 (diff) |
Allow calling a private method with `self.`
This makes it consistent with calling private attribute assignment
methods, which currently is allowed (e.g. `self.value =`).
Calling a private method in this way can be useful when trying to
assign the return value to a local variable with the same name.
[Feature #11297] [Feature #16123]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2474
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -6773,6 +6773,10 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in iseq_block_param_id_p(iseq, node->nd_recv->nd_vid, &idx, &level)) { ADD_INSN2(recv, nd_line(node->nd_recv), getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level)); } + else if (private_recv_p(node)) { + ADD_INSN(recv, nd_line(node), putself); + flag |= VM_CALL_FCALL; + } else { CHECK(COMPILE(recv, "recv", node->nd_recv)); } |