tinvalidarrayaccess.nim 385 B

12345678910111213141516171819202122
  1. discard """
  2. errormsg: "index 2 not in 0 .. 1"
  3. line: 18
  4. """
  5. block:
  6. try:
  7. let a = @[1,2]
  8. echo a[3]
  9. except Exception as e:
  10. doAssert e.msg == "index 3 not in 0 .. 1"
  11. # note: this is not being tested, because the CT error happens before
  12. block:
  13. type TTestArr = array[0..1, int16]
  14. var f: TTestArr
  15. f[0] = 30
  16. f[1] = 40
  17. f[2] = 50
  18. f[3] = 60
  19. echo(repr(f))