tdefer1.nim 483 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. discard """
  2. output: '''hi
  3. hi
  4. 1
  5. hi
  6. 2
  7. B
  8. A'''
  9. """
  10. # bug #1742
  11. template test(): untyped =
  12. let a = 0
  13. defer: echo "hi"
  14. a
  15. let i = test()
  16. import strutils
  17. let x = try: parseInt("133a")
  18. except: -1
  19. finally: echo "hi"
  20. template atFuncEnd =
  21. defer:
  22. echo "A"
  23. defer:
  24. echo "B"
  25. template testB(): untyped =
  26. let a = 0
  27. defer: echo "hi" # Delete this line to make it work
  28. a
  29. proc main =
  30. atFuncEnd()
  31. echo 1
  32. let i = testB()
  33. echo 2
  34. main()