Skip to content

Commit

Permalink
Merge pull request #1505 from quickfur/issue10874
Browse files Browse the repository at this point in the history
Issue 10874 - conv.to ulong to int enum conversion
  • Loading branch information
monarchdodra committed Aug 24, 2013
2 parents cbc684a + 8536853 commit a184d6b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,8 @@ a ConvException is thrown.
Enums with floating-point or string base types are not supported.
*/
T toImpl(T, S)(S value)
if (is(T == enum) && !is(S == enum) && is(S : OriginalType!T)
if (is(T == enum) && !is(S == enum)
&& is(typeof(value == OriginalType!T.init))
&& !isFloatingPoint!(OriginalType!T) && !isSomeString!(OriginalType!T))
{
foreach (Member; EnumMembers!T)
Expand Down Expand Up @@ -4112,3 +4113,11 @@ unittest
static assert(is(typeof(signed(cast(immutable T)1)) == long));
}
}

unittest
{
// issue 10874
enum Test { a = 0 }
ulong l = 0;
auto t = l.to!Test;
}

0 comments on commit a184d6b

Please sign in to comment.