Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit c4bc836

Browse files
authored
Merge pull request #2058 from MartinNowak/fix18252
fix Issue 18252 - comparison of arrays of associative arrays broken
2 parents e5512c4 + 589695d commit c4bc836

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/object.d

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,6 +3456,11 @@ bool __equals(T1, T2)(T1[] lhs, T2[] rhs)
34563456
if (at(lhs, u) != at(rhs, u))
34573457
return false;
34583458
}
3459+
else static if (__traits(isAssociativeArray, U1))
3460+
{
3461+
if (at(lhs, u) != at(rhs, u))
3462+
return false;
3463+
}
34593464
else
34603465
{
34613466
if (at(lhs, u).tupleof != at(rhs, u).tupleof)
@@ -3508,6 +3513,21 @@ unittest
35083513
assert(arr2 == arr3);
35093514
}
35103515

3516+
// https://issues.dlang.org/show_bug.cgi?id=18252
3517+
unittest
3518+
{
3519+
string[int][] a1, a2;
3520+
assert(__equals(a1, a2));
3521+
assert(a1 == a2);
3522+
a1 ~= [0: "zero"];
3523+
a2 ~= [0: "zero"];
3524+
assert(__equals(a1, a2));
3525+
assert(a1 == a2);
3526+
a2[0][1] = "one";
3527+
assert(!__equals(a1, a2));
3528+
assert(a1 != a2);
3529+
}
3530+
35113531
// Compare class and interface objects for ordering.
35123532
private int __cmp(Obj)(Obj lhs, Obj rhs)
35133533
if (is(Obj : Object))

0 commit comments

Comments
 (0)