diff options
author | Araq <rumpf_a@web.de> | 2017-03-30 12:53:32 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-03-30 12:53:32 +0200 |
commit | 30c99a84409f52261b124affcd06ea04ee8e23cd (patch) | |
tree | fa1dff7b1a5482666334238f363e82e4da21b1f3 /tests/exception | |
parent | 2740bcddaad3d489e116e8125f1f3f1ced250771 (diff) | |
download | Nim-30c99a84409f52261b124affcd06ea04ee8e23cd.tar.gz |
fixes #5628
Diffstat (limited to 'tests/exception')
-rw-r--r-- | tests/exception/tdont_overwrite_typename.nim | 29 |
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 |