Skip to content

Commit

Permalink
[PRISM] If receiver on CallNode is SelfNode, use FCALL flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmaissroff committed Dec 13, 2023
1 parent 1ad991c commit 798a89f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prism_compile.c
Expand Up @@ -1833,7 +1833,7 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c
}
}

if (call_node->receiver == NULL) {
if (call_node->receiver == NULL || PM_NODE_TYPE_P(call_node->receiver, PM_SELF_NODE)) {
flags |= VM_CALL_FCALL;
}

Expand Down
12 changes: 12 additions & 0 deletions test/ruby/test_compile_prism.rb
Expand Up @@ -1426,6 +1426,18 @@ def self.prism_opt_var_trail_hash(a = nil, *b, c, **d); end
prism_opt_var_trail_hash("a", "b", "c", c: 1)
prism_opt_var_trail_hash("a", "b", "c", "c" => 0, c: 1)
CODE

assert_prism_eval(<<-CODE)
class PrivateMethod
def initialize
self.instance_var
end
private
attr_accessor :instance_var
end
pm = PrivateMethod.new
pm.send(:instance_var)
CODE
end

def test_CallAndWriteNode
Expand Down

0 comments on commit 798a89f

Please sign in to comment.