tnoreturn.nim 441 B

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