summary refs log tree commit diff stats
path: root/tests/exception/tdefer1.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/exception/tdefer1.nim')
-rw-r--r--tests/exception/tdefer1.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/exception/tdefer1.nim b/tests/exception/tdefer1.nim
new file mode 100644
index 000000000..db46bad27
--- /dev/null
+++ b/tests/exception/tdefer1.nim
@@ -0,0 +1,35 @@
+discard """
+  output: '''hi
+1
+hi
+2
+B
+A'''
+"""
+
+# bug #1742
+
+import strutils
+let x = try: parseInt("133a")
+        except: -1
+        finally: echo "hi"
+
+
+template atFuncEnd =
+  defer:
+    echo "A"
+  defer:
+    echo "B"
+
+template testB(): untyped =
+    let a = 0
+    defer: echo "hi"
+    a
+
+proc main =
+  atFuncEnd()
+  echo 1
+  let i = testB()
+  echo 2
+
+main()