Skip to content

Commit

Permalink
Merge pull request #2840 from ruby/fix-up-self-write-order
Browse files Browse the repository at this point in the history
Fix up self-write order for lex
  • Loading branch information
kddnewton committed May 24, 2024
2 parents 5059526 + 8f6da45 commit 0ea3485
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -20204,7 +20204,6 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
return result;
}
case PM_CALL_NODE: {
parser_lex(parser);
pm_call_node_t *cast = (pm_call_node_t *) node;

// If we have a vcall (a method with no arguments and no
Expand All @@ -20215,13 +20214,19 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
pm_refute_numbered_parameter(parser, message_loc->start, message_loc->end);

pm_constant_id_t constant_id = pm_parser_local_add_location(parser, message_loc->start, message_loc->end, 1);
parser_lex(parser);

pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ);
pm_node_t *result = (pm_node_t *) pm_local_variable_and_write_node_create(parser, (pm_node_t *) cast, &token, value, constant_id, 0);

pm_node_destroy(parser, (pm_node_t *) cast);
return result;
}

// Move past the token here so that we have already added
// the local variable by this point.
parser_lex(parser);

// If there is no call operator and the message is "[]" then
// this is an aref expression, and we can transform it into
// an aset expression.
Expand Down Expand Up @@ -20317,7 +20322,6 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
return result;
}
case PM_CALL_NODE: {
parser_lex(parser);
pm_call_node_t *cast = (pm_call_node_t *) node;

// If we have a vcall (a method with no arguments and no
Expand All @@ -20328,13 +20332,19 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
pm_refute_numbered_parameter(parser, message_loc->start, message_loc->end);

pm_constant_id_t constant_id = pm_parser_local_add_location(parser, message_loc->start, message_loc->end, 1);
parser_lex(parser);

pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ);
pm_node_t *result = (pm_node_t *) pm_local_variable_or_write_node_create(parser, (pm_node_t *) cast, &token, value, constant_id, 0);

pm_node_destroy(parser, (pm_node_t *) cast);
return result;
}

// Move past the token here so that we have already added
// the local variable by this point.
parser_lex(parser);

// If there is no call operator and the message is "[]" then
// this is an aref expression, and we can transform it into
// an aset expression.
Expand Down

0 comments on commit 0ea3485

Please sign in to comment.