summary refs log tree commit diff stats
path: root/tests/exception
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-03-30 12:53:32 +0200
committerAraq <rumpf_a@web.de>2017-03-30 12:53:32 +0200
commit30c99a84409f52261b124affcd06ea04ee8e23cd (patch)
treefa1dff7b1a5482666334238f363e82e4da21b1f3 /tests/exception
parent2740bcddaad3d489e116e8125f1f3f1ced250771 (diff)
downloadNim-30c99a84409f52261b124affcd06ea04ee8e23cd.tar.gz
fixes #5628
Diffstat (limited to 'tests/exception')
-rw-r--r--tests/exception/tdont_overwrite_typename.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/exception/tdont_overwrite_typename.nim b/tests/exception/tdont_overwrite_typename.nim
new file mode 100644
index 000000000..147ccc001
--- /dev/null
+++ b/tests/exception/tdont_overwrite_typename.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''Check passed
+Check passed'''
+"""
+
+# bug #5628
+
+proc checkException(ex: ref Exception) =
+  doAssert(ex.name == "ValueError")
+  doAssert(ex.msg == "SecondException")
+  doAssert(ex.parent != nil)
+  doAssert(ex.parent.name == "KeyError")
+  doAssert(ex.parent.msg == "FirstException")
+  echo "Check passed"
+
+var e: ref Exception
+try:
+  try:
+    raise newException(KeyError, "FirstException")
+  except:
+    raise newException(ValueError, "SecondException", getCurrentException())
+except:
+  e = getCurrentException()
+
+try:
+  checkException(e) # passes here
+  raise e
+except ValueError:
+  checkException(getCurrentException()) # fails here