summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorhlaaftana <10591326+hlaaftana@users.noreply.github.com>2021-02-01 22:14:20 +0300
committerGitHub <noreply@github.com>2021-02-01 20:14:20 +0100
commitdef1f99289022a57e8edc3ffc296dd3a0f9b19c9 (patch)
tree3c3479ba22159be09a6cc571e3cc6b2b40ed1fe0 /compiler
parent91ace2188a243b4453412ed1e79e2efcc62d95a6 (diff)
downloadNim-def1f99289022a57e8edc3ffc296dd3a0f9b19c9.tar.gz
add finally as post expr block [backport:1.4] (#16896)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index be39a6bc1..fe82da594 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -1308,6 +1308,7 @@ proc postExprBlocks(p: var Parser, x: PNode): PNode =
   #|                            | IND{=} 'of' exprList ':' stmt
   #|                            | IND{=} 'elif' expr ':' stmt
   #|                            | IND{=} 'except' exprList ':' stmt
+  #|                            | IND{=} 'finally' ':' stmt
   #|                            | IND{=} 'else' ':' stmt )*
   result = x
   if p.tok.indent >= 0: return
@@ -1362,6 +1363,9 @@ proc postExprBlocks(p: var Parser, x: PNode): PNode =
         of tkExcept:
           nextBlock = newNodeP(nkExceptBranch, p)
           exprList(p, tkColon, nextBlock)
+        of tkFinally:
+          nextBlock = newNodeP(nkFinally, p)
+          getTok(p)
         of tkElse:
           nextBlock = newNodeP(nkElse, p)
           getTok(p)
@@ -1372,7 +1376,7 @@ proc postExprBlocks(p: var Parser, x: PNode): PNode =
       nextBlock.flags.incl nfBlockArg
       result.add nextBlock
 
-      if nextBlock.kind == nkElse: break
+      if nextBlock.kind in {nkElse, nkFinally}: break
   else:
     if openingParams.kind != nkEmpty:
       parMessage(p, "expected ':'")