summary refs log tree commit diff stats
path: root/tests/destructor
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2020-01-10 01:51:06 +0100
committerAndreas Rumpf <rumpf_a@web.de>2020-01-10 08:32:30 +0100
commitfcd2f305ad5ad2af37284caf7b33907afb8ad834 (patch)
treeca433474a62522eecc978ee08bf5badbbd78a6b8 /tests/destructor
parent033da35de164e4ea86e36c8c4bb366f3fc4ac01a (diff)
downloadNim-fcd2f305ad5ad2af37284caf7b33907afb8ad834.tar.gz
fixes #13070
Diffstat (limited to 'tests/destructor')
-rw-r--r--tests/destructor/tgotoexceptions4.nim40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/destructor/tgotoexceptions4.nim b/tests/destructor/tgotoexceptions4.nim
new file mode 100644
index 000000000..918169084
--- /dev/null
+++ b/tests/destructor/tgotoexceptions4.nim
@@ -0,0 +1,40 @@
+discard """
+  cmd: "nim c --gc:arc --exceptions:goto $file"
+  output: '''caught in gun
+caught in fun
+caughtsome msgMyExcept
+in finally
+caught1'''
+"""
+
+when true:
+  # bug #13070
+  type MyExcept = object of CatchableError
+  proc gun() =
+    try:
+      raise newException(MyExcept, "some msg")
+    except Exception as eab:
+      echo "caught in gun"
+      raise eab
+
+  proc fun() =
+    try:
+      gun()
+    except Exception as e:
+      echo "caught in fun"
+      echo("caught", e.msg, e.name)
+    finally:
+      echo "in finally"
+  fun()
+
+when true:
+  # bug #13072
+  type MyExceptB = object of CatchableError
+  proc gunB() =
+    raise newException(MyExceptB, "some msg")
+  proc funB() =
+    try:
+      gunB()
+    except CatchableError:
+      echo "caught1"
+  funB()