summary refs log blame commit diff stats
path: root/tests/exception/tdefer1.nim
blob: db46bad2746cbf29af082f86ceb88c48a68fce59 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

               

  
 

    



           



                             







                    
                           
             
                    








                 
discard """
  output: '''hi
1
hi
2
B
A'''
"""

# bug #1742

import strutils
let x = try: parseInt("133a")
        except: -1
        finally: echo "hi"


template atFuncEnd =
  defer:
    echo "A"
  defer:
    echo "B"

template testB(): untyped =
    let a = 0
    defer: echo "hi"
    a

proc main =
  atFuncEnd()
  echo 1
  let i = testB()
  echo 2

main()