Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ Associative array to associative array conversion converts each key
and each value in turn.
*/
private T toImpl(T, S)(S value)
if (isAssociativeArray!S &&
if (!isImplicitlyConvertible!(S, T) && isAssociativeArray!S &&
isAssociativeArray!T && !is(T == enum))
{
/* This code is potentially unsafe.
Expand Down Expand Up @@ -1619,6 +1619,16 @@ if (isAssociativeArray!S &&
auto d = to!(immutable(short[immutable wstring])[immutable string[double[]]])(c);
}

@safe unittest
{
import std.algorithm.comparison : equal;
import std.array : byPair;

int[int] a;
assert(a.to!(int[int]) == a);
assert(a.to!(const(int)[int]).byPair.equal(a.byPair));
}

private void testIntegralToFloating(Integral, Floating)()
{
Integral a = 42;
Expand Down