Skip to content

Commit d931e25

Browse files
committed
Handle infinite opt terms after missing case predicate
1 parent 7c38d6d commit d931e25

File tree

3 files changed

+49
-34
lines changed

3 files changed

+49
-34
lines changed

src/yarp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11703,11 +11703,12 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
1170311703
yp_token_t case_keyword = parser->previous;
1170411704
yp_node_t *predicate = NULL;
1170511705

11706-
if (
11707-
accept2(parser, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON) ||
11708-
match3(parser, YP_TOKEN_KEYWORD_WHEN, YP_TOKEN_KEYWORD_IN, YP_TOKEN_KEYWORD_END) ||
11709-
!token_begins_expression_p(parser->current.type)
11710-
) {
11706+
if (accept2(parser, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON)) {
11707+
while (accept2(parser, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON));
11708+
predicate = NULL;
11709+
} else if (match3(parser, YP_TOKEN_KEYWORD_WHEN, YP_TOKEN_KEYWORD_IN, YP_TOKEN_KEYWORD_END)) {
11710+
predicate = NULL;
11711+
} else if (!token_begins_expression_p(parser->current.type)) {
1171111712
predicate = NULL;
1171211713
} else {
1171311714
predicate = parse_expression(parser, YP_BINDING_POWER_COMPOSITION, YP_ERR_CASE_EXPRESSION_AFTER_CASE);

test/yarp/fixtures/case.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ case type;
2828
;when :b;
2929
; else;
3030
end
31+
32+
case ;;;;;;;; when 1; end

test/yarp/snapshots/case.txt

Lines changed: 41 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)