tnestedreturn.nim 484 B

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