summaryrefslogtreecommitdiff
path: root/prism_compile.c
diff options
context:
space:
mode:
authortomoya ishida <[email protected]>2025-01-07 05:06:02 +0900
committerGitHub <[email protected]>2025-01-07 05:06:02 +0900
commit8fb17f86d7ef2a84f82c83a9509e311a07aa93fc (patch)
treeabfa3fc07a4bc87364f03d5c8993f86a5dd8bf34 /prism_compile.c
parent5698f4f2e1b8221a68989f881c03a41175736a8a (diff)
[Bug #21006] Fix defined_expr compilation of method call with parenth… (#12518)
[Bug #21006] Fix defined_expr compilation of method call with parenthesized receiver
Diffstat (limited to 'prism_compile.c')
-rw-r--r--prism_compile.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/prism_compile.c b/prism_compile.c
index a47e669d72..3894bed141 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -3755,7 +3755,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
const pm_node_list_t *arguments = &cast->arguments;
for (size_t idx = 0; idx < arguments->size; idx++) {
const pm_node_t *argument = arguments->nodes[idx];
- pm_compile_defined_expr0(iseq, argument, node_location, ret, popped, scope_node, in_condition, lfinish, explicit_receiver);
+ pm_compile_defined_expr0(iseq, argument, node_location, ret, popped, scope_node, in_condition, lfinish, false);
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(location.line);
@@ -3778,7 +3778,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
else if (PM_NODE_TYPE_P(cast->body, PM_STATEMENTS_NODE) && ((const pm_statements_node_t *) cast->body)->body.size == 1) {
// If we have a parentheses node that is wrapping a single statement
// then we want to recurse down to that statement and compile it.
- pm_compile_defined_expr0(iseq, ((const pm_statements_node_t *) cast->body)->body.nodes[0], node_location, ret, popped, scope_node, in_condition, lfinish, explicit_receiver);
+ pm_compile_defined_expr0(iseq, ((const pm_statements_node_t *) cast->body)->body.nodes[0], node_location, ret, popped, scope_node, in_condition, lfinish, false);
return;
}
else {
@@ -3874,7 +3874,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
}
case PM_IMPLICIT_NODE: {
const pm_implicit_node_t *cast = (const pm_implicit_node_t *) node;
- pm_compile_defined_expr0(iseq, cast->value, node_location, ret, popped, scope_node, in_condition, lfinish, explicit_receiver);
+ pm_compile_defined_expr0(iseq, cast->value, node_location, ret, popped, scope_node, in_condition, lfinish, false);
return;
}
case PM_AND_NODE:
@@ -4018,9 +4018,8 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
}
if (cast->receiver) {
- pm_compile_defined_expr0(iseq, cast->receiver, node_location, ret, popped, scope_node, true, lfinish, true);
-
if (PM_NODE_TYPE_P(cast->receiver, PM_CALL_NODE) && !BLOCK_P((const pm_call_node_t *) cast->receiver)) {
+ pm_compile_defined_expr0(iseq, cast->receiver, node_location, ret, popped, scope_node, true, lfinish, true);
PUSH_INSNL(ret, location, branchunless, lfinish[2]);
const pm_call_node_t *receiver = (const pm_call_node_t *) cast->receiver;
@@ -4028,6 +4027,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
pm_compile_call(iseq, receiver, ret, popped, scope_node, method_id, NULL);
}
else {
+ pm_compile_defined_expr0(iseq, cast->receiver, node_location, ret, popped, scope_node, true, lfinish, false);
PUSH_INSNL(ret, location, branchunless, lfinish[1]);
PM_COMPILE(cast->receiver);
}
@@ -4106,7 +4106,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
}
static void
-pm_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition, LABEL **lfinish, bool explicit_receiver)
+pm_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition, LABEL **lfinish)
{
LINK_ELEMENT *lcur = ret->last;
pm_compile_defined_expr0(iseq, node, node_location, ret, popped, scope_node, in_condition, lfinish, false);
@@ -4147,7 +4147,7 @@ pm_compile_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_lo
lfinish[2] = 0;
if (!popped) {
- pm_defined_expr(iseq, node, node_location, ret, popped, scope_node, in_condition, lfinish, false);
+ pm_defined_expr(iseq, node, node_location, ret, popped, scope_node, in_condition, lfinish);
}
if (lfinish[1]) {