tnestedreturn.nim 512 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. discard """
  2. targets: "c cpp"
  3. file: "tnestedreturn.nim"
  4. output: "A\nB\nC\n"
  5. """
  6. # Various tests of return nested in double try/except statements
  7. proc test1() =
  8. defer: echo "A"
  9. try:
  10. raise newException(OSError, "Problem")
  11. except OSError:
  12. return
  13. test1()
  14. proc test2() =
  15. defer: echo "B"
  16. try:
  17. return
  18. except OSError:
  19. discard
  20. test2()
  21. proc test3() =
  22. try:
  23. try:
  24. raise newException(OSError, "Problem")
  25. except OSError:
  26. return
  27. finally:
  28. echo "C"
  29. test3()