tconv.nim 688 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. template reject(x) =
  2. static: assert(not compiles(x))
  3. reject:
  4. const x = int8(300)
  5. reject:
  6. const x = int64(NaN)
  7. type
  8. R = range[0..10]
  9. reject:
  10. const x = R(11)
  11. reject:
  12. const x = R(11.0)
  13. reject:
  14. const x = R(NaN)
  15. reject:
  16. const x = R(Inf)
  17. type
  18. FloatRange = range[0'f..10'f]
  19. reject:
  20. const x = FloatRange(-1'f)
  21. reject:
  22. const x = FloatRange(-1)
  23. reject:
  24. const x = FloatRange(NaN)
  25. block:
  26. const x = float32(NaN)
  27. type E = enum a, b, c
  28. reject:
  29. const e = E(4)
  30. block: # issue 3766
  31. type R = range[0..2]
  32. reject:
  33. type
  34. T[n: static[R]] = object
  35. V = T[3.R]
  36. reject:
  37. proc r(x: static[R]) =
  38. echo x
  39. r 3.R