summary refs log tree commit diff stats
path: root/tests/misc/tinvalidarrayaccess.nim
blob: 57ad38b85e679540f77ac82d4688a5429de9c752 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
discard """
  errormsg: "index out of bounds: (a:0) <= (i:2) <= (b:1) "
  line: 18
"""

block:
  try:
    let a = @[1,2]
    echo a[3]
  except Exception as e:
    doAssert e.msg == "index out of bounds: (i:3) <= (n:1) "

block:
  type TTestArr = array[0..1, int16]
  var f: TTestArr
  f[0] = 30
  f[1] = 40
  f[2] = 50
  f[3] = 60

  echo(repr(f))