diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-02-14 14:29:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 07:29:30 +0100 |
commit | 406d3021314c66fdf4c715efeeaea3c8f478fcaa (patch) | |
tree | e90061bdcc0c07dec0a65a27b060cb5d7037c968 | |
parent | 684c3b3aeb90ae549382ed0f9c3286464c72809f (diff) | |
download | Nim-406d3021314c66fdf4c715efeeaea3c8f478fcaa.tar.gz |
allow omitting stmts using `finally` as post expr blocks; make it consistent with `else`, `except` etc. (#21361)
allow omitting stmts using `finally` as post expr blocks
-rw-r--r-- | compiler/parser.nim | 2 | ||||
-rw-r--r-- | tests/parser/tpostexprblocks.nim | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 14882d415..abfc7b323 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1496,7 +1496,7 @@ proc postExprBlocks(p: var Parser, x: PNode): PNode = result = makeCall(result) getTok(p) skipComment(p, result) - if p.tok.tokType notin {tkOf, tkElif, tkElse, tkExcept}: + if p.tok.tokType notin {tkOf, tkElif, tkElse, tkExcept, tkFinally}: var stmtList = newNodeP(nkStmtList, p) stmtList.add parseStmt(p) # to keep backwards compatibility (see tests/vm/tstringnil) diff --git a/tests/parser/tpostexprblocks.nim b/tests/parser/tpostexprblocks.nim index d272c712f..6cd4a8350 100644 --- a/tests/parser/tpostexprblocks.nim +++ b/tests/parser/tpostexprblocks.nim @@ -498,6 +498,13 @@ StmtList StmtList DiscardStmt Empty + + Call + Ident "foo" + Finally + StmtList + DiscardStmt + Empty ''' """ @@ -655,3 +662,7 @@ dumpTree: discard finally: discard + + foo: + finally: + discard |