diff options
Diffstat (limited to 'tests/ccgbugs/t21972.nim')
-rw-r--r-- | tests/ccgbugs/t21972.nim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ccgbugs/t21972.nim b/tests/ccgbugs/t21972.nim new file mode 100644 index 000000000..58d0cfc62 --- /dev/null +++ b/tests/ccgbugs/t21972.nim @@ -0,0 +1,33 @@ +discard """ + targets: "c cpp" + outputsub: "Error: unhandled exception: Err2 [IOError]" + exitcode: "1" +""" + +proc bar(x: var int) = + inc x + if x == 3: + raise newException(ValueError, "H0") + + elif x == 5: + raise newException(IOError, "H1") + + elif x > 7: + raise newException(IOError, "H2") + + +proc foo() = + var i = 0 + while true: + try: + bar(i) + echo i + + except ValueError: + debugEcho("ValueError") + + except IOError: + raise newException(IOError, "Err2") + +when isMainModule: + foo() \ No newline at end of file |