summary refs log tree commit diff stats
path: root/tests/ccgbugs/t21972.nim
blob: 58d0cfc6292f2c373c6833ef4c3c69c6a73e846c (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
discard """
    targets: "c cpp"
    outputsub: "Error: unhandled exception: Err2 [IOError]"
    exitcode: "1"
"""

proc bar(x: var int) =
  inc x
  if x == 3:
    raise newException(ValueError, "H0")

  elif x == 5:
    raise newException(IOError, "H1")

  elif x > 7:
    raise newException(IOError, "H2")


proc foo() =
  var i = 0
  while true:
    try:
      bar(i)
      echo i

    except ValueError:
      debugEcho("ValueError")

    except IOError:
      raise newException(IOError, "Err2")

when isMainModule:
  foo()