gh-129858: Special syntax error for elif block after else (#129902)

This commit is contained in:
Steele Farnsworth 2025-04-24 21:25:48 -04:00 committed by GitHub
parent c3a7118065
commit 99b71efe8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 137 additions and 75 deletions

View file

@ -1422,6 +1422,7 @@ invalid_elif_stmt:
invalid_else_stmt:
| a='else' ':' NEWLINE !INDENT {
RAISE_INDENTATION_ERROR("expected an indented block after 'else' statement on line %d", a->lineno) }
| 'else' ':' block 'elif' { RAISE_SYNTAX_ERROR("'elif' block follows an 'else' block")}
invalid_while_stmt:
| 'while' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
| a='while' named_expression ':' NEWLINE !INDENT {