tunreachable.nim 629 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. cmd: "nim check --warningAsError:UnreachableCode $file"
  3. action: "reject"
  4. nimout: '''
  5. tunreachable.nim(23, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
  6. tunreachable.nim(30, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
  7. '''
  8. """
  9. # bug #9839
  10. template myquit1():untyped=
  11. ## foo
  12. quit(1)
  13. template myquit2():untyped=
  14. echo 123
  15. myquit1()
  16. proc main1()=
  17. # BUG: uncommenting this doesn't give `Error: unreachable statement`
  18. myquit2()
  19. echo "after"
  20. main1()
  21. proc main2() =
  22. myquit1()
  23. echo "after"
  24. main2()