fixes #21144; try expression will not match the less indentation except (#21152)

fixes #21144; try expression will not match the less indent except
This commit is contained in:
ringabout 2022-12-22 04:46:14 +08:00 • committed by GitHub
commit d0721eadf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

@ -1770,11 +1770,13 @@ proc parseTry(p: var Parser; isExpr: bool): PNode =
#| (optInd 'except' optionalExprList colcom stmt)*
#| (optInd 'finally' colcom stmt)?
result = newNodeP(nkTryStmt, p)
let parentIndent = p.currInd # isExpr
getTok(p)
colcom(p, result)
result.add(parseStmt(p))
var b: PNode = nil
while sameOrNoInd(p) or isExpr:
while sameOrNoInd(p) or (isExpr and parentIndent <= p.tok.indent):
case p.tok.tokType
of tkExcept:
b = newNodeP(nkExceptBranch, p)