summary refs log tree commit diff stats
path: root/tests/stdlib/tsegfaults.nim
blob: 1d8508c52bd9eb491a00803508bf1a2ad5c667dd (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
discard """
  output: '''caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!
caught a crash!'''
"""

import segfaults

proc main =
  try:
    var x: ptr int
    echo x[]
    try:
      raise newException(ValueError, "not a crash")
    except ValueError:
      discard
  except NilAccessError:
    echo "caught a crash!"

for i in 0..10:
  main()