From 88c2c81fbcc8cbc718f1f7bdbf7da017a18a2516 Mon Sep 17 00:00:00 2001 From: Andrej Mitrovic Date: Sun, 20 Jan 2013 17:29:27 +0100 Subject: [PATCH] Fixes Issue 6668 - Avoid throwing collateral exceptions in std.conv.to --- std/conv.d | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/std/conv.d b/std/conv.d index a96b4678d8f..97f3781ee0b 100644 --- a/std/conv.d +++ b/std/conv.d @@ -1608,7 +1608,7 @@ T toImpl(T, S)(S value) if ( isExactSomeString!S && isDynamicArray!S && !isExactSomeString!T && is(typeof(parse!T(value)))) { - scope(exit) + scope(success) { if (value.length) { @@ -1623,7 +1623,7 @@ T toImpl(T, S)(S value, uint radix) if ( isExactSomeString!S && isDynamicArray!S && !isExactSomeString!T && is(typeof(parse!T(value, radix)))) { - scope(exit) + scope(success) { if (value.length) { @@ -1633,6 +1633,13 @@ T toImpl(T, S)(S value, uint radix) return parse!T(value, radix); } +unittest +{ + // Issue 6668 - ensure no collaterals thrown + try { to!uint("-1"); } + catch (ConvException e) { assert(e.next is null); } +} + unittest { debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded.");