Skip to content

Commit 8f6da45

Browse files
committed
Fix up self-write order for lex
1 parent 5059526 commit 8f6da45

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/prism.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20204,7 +20204,6 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
2020420204
return result;
2020520205
}
2020620206
case PM_CALL_NODE: {
20207-
parser_lex(parser);
2020820207
pm_call_node_t *cast = (pm_call_node_t *) node;
2020920208

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

2021720216
pm_constant_id_t constant_id = pm_parser_local_add_location(parser, message_loc->start, message_loc->end, 1);
20217+
parser_lex(parser);
20218+
2021820219
pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ);
2021920220
pm_node_t *result = (pm_node_t *) pm_local_variable_and_write_node_create(parser, (pm_node_t *) cast, &token, value, constant_id, 0);
2022020221

2022120222
pm_node_destroy(parser, (pm_node_t *) cast);
2022220223
return result;
2022320224
}
2022420225

20226+
// Move past the token here so that we have already added
20227+
// the local variable by this point.
20228+
parser_lex(parser);
20229+
2022520230
// If there is no call operator and the message is "[]" then
2022620231
// this is an aref expression, and we can transform it into
2022720232
// an aset expression.
@@ -20317,7 +20322,6 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
2031720322
return result;
2031820323
}
2031920324
case PM_CALL_NODE: {
20320-
parser_lex(parser);
2032120325
pm_call_node_t *cast = (pm_call_node_t *) node;
2032220326

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

2033020334
pm_constant_id_t constant_id = pm_parser_local_add_location(parser, message_loc->start, message_loc->end, 1);
20335+
parser_lex(parser);
20336+
2033120337
pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ);
2033220338
pm_node_t *result = (pm_node_t *) pm_local_variable_or_write_node_create(parser, (pm_node_t *) cast, &token, value, constant_id, 0);
2033320339

2033420340
pm_node_destroy(parser, (pm_node_t *) cast);
2033520341
return result;
2033620342
}
2033720343

20344+
// Move past the token here so that we have already added
20345+
// the local variable by this point.
20346+
parser_lex(parser);
20347+
2033820348
// If there is no call operator and the message is "[]" then
2033920349
// this is an aref expression, and we can transform it into
2034020350
// an aset expression.

0 commit comments

Comments
 (0)