tstrict_effects_sort.nim 479 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. errormsg: "cmpE can raise an unlisted exception: Exception"
  3. line: 27
  4. """
  5. {.push warningAsError[Effect]: on.}
  6. {.experimental: "strictEffects".}
  7. import algorithm
  8. type
  9. MyInt = distinct int
  10. var toSort = @[MyInt 1, MyInt 2, MyInt 3]
  11. proc cmpN(a, b: MyInt): int =
  12. cmp(a.int, b.int)
  13. proc harmless {.raises: [].} =
  14. toSort.sort cmpN
  15. proc cmpE(a, b: MyInt): int {.raises: [Exception].} =
  16. cmp(a.int, b.int)
  17. proc harmfull {.raises: [].} =
  18. toSort.sort cmpE