summary refs log tree commit diff stats
path: root/tests/exception/tdefer1.nim
blob: b84ba768109d7d104467ed7588b00813745b78d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
discard """
  output: '''hi
hi
1
hi
2
B
A'''
"""

# bug #1742

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

let i = test()

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" # Delete this line to make it work
    a

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

main()