tnoreturn.nim 461 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. matrix: "--mm:refc"
  3. ccodeCheck: "\\i @'__attribute__((noreturn))' .*"
  4. action: compile
  5. """
  6. proc noret1*(i: int) {.noreturn.} =
  7. echo i
  8. proc noret2*(i: int): void {.noreturn.} =
  9. echo i
  10. if true: noret1(1)
  11. if true: noret2(2)
  12. var p {.used.}: proc(i: int): int
  13. doAssert(not compiles(
  14. p = proc(i: int): int {.noreturn.} = i # noreturn lambda returns int
  15. ))
  16. doAssert(not compiles(
  17. block:
  18. noret1(5)
  19. echo 1 # statement after noreturn
  20. ))