diff options
Diffstat (limited to 'tests/exception/tdefer1.nim')
-rw-r--r-- | tests/exception/tdefer1.nim | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/exception/tdefer1.nim b/tests/exception/tdefer1.nim index 61439530a..d7c691713 100644 --- a/tests/exception/tdefer1.nim +++ b/tests/exception/tdefer1.nim @@ -1,6 +1,10 @@ discard """ output: '''hi -hi''' +hi +1 +hi +B +A''' """ # bug #1742 @@ -16,3 +20,23 @@ import strutils let x = try: parseInt("133a") except: -1 finally: echo "hi" + + +template atFuncEnd = + defer: + echo "A" + defer: + echo "B" + +template testB(): expr = + let a = 0 + defer: echo "hi" # Delete this line to make it work + a + +proc main = + atFuncEnd() + echo 1 + let i = testB() + echo 2 + +main() |