Skip to content

Commit 62f736f

Browse files
kddnewtonk0kubun
authored andcommitted
Backport Bug #21137
1 parent eaa26b8 commit 62f736f

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

prism/prism.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5653,8 +5653,7 @@ pm_lambda_node_create(
56535653
*/
56545654
static pm_local_variable_and_write_node_t *
56555655
pm_local_variable_and_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value, pm_constant_id_t name, uint32_t depth) {
5656-
assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE));
5657-
assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
5656+
assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_IT_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE)); assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
56585657
pm_local_variable_and_write_node_t *node = PM_NODE_ALLOC(parser, pm_local_variable_and_write_node_t);
56595658

56605659
*node = (pm_local_variable_and_write_node_t) {
@@ -5708,7 +5707,7 @@ pm_local_variable_operator_write_node_create(pm_parser_t *parser, pm_node_t *tar
57085707
*/
57095708
static pm_local_variable_or_write_node_t *
57105709
pm_local_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value, pm_constant_id_t name, uint32_t depth) {
5711-
assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE));
5710+
assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_IT_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE));
57125711
assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
57135712
pm_local_variable_or_write_node_t *node = PM_NODE_ALLOC(parser, pm_local_variable_or_write_node_t);
57145713

@@ -21066,6 +21065,17 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
2106621065
pm_node_destroy(parser, node);
2106721066
return result;
2106821067
}
21068+
case PM_IT_LOCAL_VARIABLE_READ_NODE: {
21069+
pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
21070+
parser_lex(parser);
21071+
21072+
pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
21073+
pm_node_t *result = (pm_node_t *) pm_local_variable_and_write_node_create(parser, node, &token, value, name, 0);
21074+
21075+
parse_target_implicit_parameter(parser, node);
21076+
pm_node_destroy(parser, node);
21077+
return result;
21078+
}
2106921079
case PM_LOCAL_VARIABLE_READ_NODE: {
2107021080
if (pm_token_is_numbered_parameter(node->location.start, node->location.end)) {
2107121081
PM_PARSER_ERR_FORMAT(parser, node->location.start, node->location.end, PM_ERR_PARAMETER_NUMBERED_RESERVED, node->location.start);
@@ -21189,6 +21199,17 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
2118921199
pm_node_destroy(parser, node);
2119021200
return result;
2119121201
}
21202+
case PM_IT_LOCAL_VARIABLE_READ_NODE: {
21203+
pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
21204+
parser_lex(parser);
21205+
21206+
pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
21207+
pm_node_t *result = (pm_node_t *) pm_local_variable_or_write_node_create(parser, node, &token, value, name, 0);
21208+
21209+
parse_target_implicit_parameter(parser, node);
21210+
pm_node_destroy(parser, node);
21211+
return result;
21212+
}
2119221213
case PM_LOCAL_VARIABLE_READ_NODE: {
2119321214
if (pm_token_is_numbered_parameter(node->location.start, node->location.end)) {
2119421215
PM_PARSER_ERR_FORMAT(parser, node->location.start, node->location.end, PM_ERR_PARAMETER_NUMBERED_RESERVED, node->location.start);
@@ -21322,6 +21343,17 @@ parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t
2132221343
pm_node_destroy(parser, node);
2132321344
return result;
2132421345
}
21346+
case PM_IT_LOCAL_VARIABLE_READ_NODE: {
21347+
pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
21348+
parser_lex(parser);
21349+
21350+
pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, accepts_command_call, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
21351+
pm_node_t *result = (pm_node_t *) pm_local_variable_operator_write_node_create(parser, node, &token, value, name, 0);
21352+
21353+
parse_target_implicit_parameter(parser, node);
21354+
pm_node_destroy(parser, node);
21355+
return result;
21356+
}
2132521357
case PM_LOCAL_VARIABLE_READ_NODE: {
2132621358
if (pm_token_is_numbered_parameter(node->location.start, node->location.end)) {
2132721359
PM_PARSER_ERR_FORMAT(parser, node->location.start, node->location.end, PM_ERR_PARAMETER_NUMBERED_RESERVED, node->location.start);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
tap { it += 1 }
2+
3+
tap { it ||= 1 }
4+
5+
tap { it &&= 1 }
6+
7+
tap { it; it += 1 }
8+
9+
tap { it; it ||= 1 }
10+
11+
tap { it; it &&= 1 }
12+
13+
tap { it += 1; it }
14+
15+
tap { it ||= 1; it }
16+
17+
tap { it &&= 1; it }
18+
19+
tap { it; it += 1; it }
20+
21+
tap { it; it ||= 1; it }
22+
23+
tap { it; it &&= 1; it }

0 commit comments

Comments
 (0)