Skip to content

Commit 4ccaed2

Browse files
kddnewtonmatzbot
authored andcommitted
[ruby/prism] Fix accepting newline in multitarget before =
ruby/prism@3c89c5606d
1 parent 67334c0 commit 4ccaed2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

prism/prism.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13423,7 +13423,13 @@ parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t b
1342313423
static pm_node_t *
1342413424
parse_targets_validate(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t binding_power, uint16_t depth) {
1342513425
pm_node_t *result = parse_targets(parser, first_target, binding_power, depth);
13426-
accept1(parser, PM_TOKEN_NEWLINE);
13426+
13427+
// If we're inside parentheses, then we allow a newline before the
13428+
// closing parenthesis or equals sign. Outside of parentheses, a newline
13429+
// is not allowed (e.g., `a, b\n= 1, 2` is not valid).
13430+
if (context_p(parser, PM_CONTEXT_PARENS) || context_p(parser, PM_CONTEXT_MULTI_TARGET)) {
13431+
accept1(parser, PM_TOKEN_NEWLINE);
13432+
}
1342713433

1342813434
// Ensure that we have either an = or a ) after the targets.
1342913435
if (!match2(parser, PM_TOKEN_EQUAL, PM_TOKEN_PARENTHESIS_RIGHT)) {

0 commit comments

Comments
 (0)