File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1503,7 +1503,7 @@ invalid_case_block:
15031503 | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
15041504 | a="case" patterns guard? ':' NEWLINE !INDENT {
15051505 RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
1506- | !"case" { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("expected 'case' statement inside 'match' statement") }
1506+ | !( "case" | DEDENT) { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("expected 'case' statement inside 'match' statement") }
15071507invalid_as_pattern:
15081508 | or_pattern 'as' a="_" { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use '_' as a target") }
15091509 | or_pattern 'as' a=expression {
Original file line number Diff line number Diff line change 419419Traceback (most recent call last):
420420SyntaxError: invalid syntax. Perhaps you forgot a comma?
421421
422+ # Make sure syntax error after match block doesn't raise a specialized
423+ # 'expected case statement' error.
424+
425+ >>> match 1:
426+ ... case 1:
427+ ... pass
428+ ... 1 2
429+ Traceback (most recent call last):
430+ SyntaxError: invalid syntax
431+
422432From compiler_complex_args():
423433
424434>>> def f(None=1):
@@ -3472,7 +3482,7 @@ def test_match_stmt_contains_invalid_stmt(self):
34723482 "a = 1" ,
34733483 "if a:" ,
34743484 "else:" ,
3475- "match 1:"
3485+ "match 1:" ,
34763486 "pass" ,
34773487 "return" ,
34783488 "return 2" ,
You can’t perform that action at this time.
0 commit comments