[Issue 22065] New: std.container.array: compiler allows Array as the key of an associative array but this does not work properly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 22 11:19:46 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22065

          Issue ID: 22065
           Summary: std.container.array: compiler allows Array as the key
                    of an associative array but this does not work
                    properly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

Equality and hashing are inconsistent for std.container.array.Array leading to
incorrect behavior when an Array is used as the key of an associative array.

---
void main()
{
    import std.container.array : Array;

    int[Array!int] aa;
    auto a = Array!int(1, 2, 3);
    aa[a] = 9;
    assert(aa[a] == 9); // Passes.

    auto b = Array!int(1, 2, 3);
    assert(a == b); // Passes.
    assert(aa[b] == 9); // Fails: range violation.
}
---

--


More information about the Digitalmars-d-bugs mailing list