The else clause now must be located right after the last except clause in try blocks

This commit is contained in:
Nocturn9x 2022-03-14 08:53:23 +01:00
parent 9babc75995
commit bfdfb73fc9
1 changed files with 2 additions and 2 deletions

View File

@ -724,10 +724,10 @@ proc tryStmt(self: Parser): ASTNode =
handlerBody = self.statement()
handlers.add((body: handlerBody, exc: excName, name: asName))
asName = nil
if self.match(Finally):
finallyClause = self.statement()
if self.match(Else):
elseClause = self.statement()
if self.match(Finally):
finallyClause = self.statement()
if handlers.len() == 0 and elseClause == nil and finallyClause == nil:
self.error("expecting 'except', 'finally' or 'else' statements after 'try' block")
for i, handler in handlers: