@@ -10692,8 +10692,12 @@ static pm_node_t *
10692
10692
parse_target_validate(pm_parser_t *parser, pm_node_t *target) {
10693
10693
pm_node_t *result = parse_target(parser, target);
10694
10694
10695
- // Ensure that we have either an = or a ) after the targets.
10696
- if (!match3(parser, PM_TOKEN_EQUAL, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_KEYWORD_IN)) {
10695
+ // Ensure that we have one of an =, an 'in' in for indexes, and a ')' in parens after the targets.
10696
+ if (
10697
+ !match1(parser, PM_TOKEN_EQUAL) &&
10698
+ !(context_p(parser, PM_CONTEXT_FOR_INDEX) && match1(parser, PM_TOKEN_KEYWORD_IN)) &&
10699
+ !(context_p(parser, PM_CONTEXT_PARENS) && match1(parser, PM_TOKEN_PARENTHESIS_RIGHT))
10700
+ ) {
10697
10701
pm_parser_err_node(parser, result, PM_ERR_WRITE_TARGET_UNEXPECTED);
10698
10702
}
10699
10703
@@ -13746,7 +13750,9 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) {
13746
13750
// Otherwise, we're going to parse the first statement in the list
13747
13751
// of statements within the parentheses.
13748
13752
pm_accepts_block_stack_push(parser, true);
13753
+ context_push(parser, PM_CONTEXT_PARENS);
13749
13754
pm_node_t *statement = parse_expression(parser, PM_BINDING_POWER_STATEMENT, PM_ERR_CANNOT_PARSE_EXPRESSION);
13755
+ context_pop(parser);
13750
13756
13751
13757
// Determine if this statement is followed by a terminator. In the
13752
13758
// case of a single statement, this is fine. But in the case of
0 commit comments