Permalink
Browse files

Fixes Issue 6668 - Avoid throwing collateral exceptions in std.conv.to

  • Loading branch information...
1 parent 191241f commit 88c2c81fbcc8cbc718f1f7bdbf7da017a18a2516 @AndrejMitrovic AndrejMitrovic committed Jan 20, 2013
Showing with 9 additions and 2 deletions.
  1. +9 −2 std/conv.d
View
@@ -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.");

0 comments on commit 88c2c81

Please sign in to comment.