toutofrangevarconv.nim 260 B

123456789101112131415
  1. discard """
  2. outputsub: "value out of range: 5 notin 0 .. 3 [RangeDefect]"
  3. exitcode: "1"
  4. """
  5. # make sure out of bounds range conversion is detected for `var` conversions
  6. type R = range[0..3]
  7. proc foo(x: var R) =
  8. doAssert x in 0..3
  9. var x = 5
  10. foo(R(x))