June 22, 2021 [Issue 22065] New: std.container.array: compiler allows Array as the key of an associative array but this does not work properly | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: n8sh.secondary@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. } --- -- |
Copyright © 1999-2021 by the D Language Foundation