[Issue 12140] New: SortedRange as associative array keys
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 12 04:50:38 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12140
Summary: SortedRange as associative array keys
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2014-02-12 04:50:36 PST ---
It seems a SortedRange doesn't define a proper hash protocol:
void main() {
import std.algorithm: sort;
import std.range: SortedRange;
int[SortedRange!(dchar[], "a < b")] AA;
dchar[] a = "hello"d.dup;
dchar[] b = a.dup;
AA[a.sort()] = 5;
AA[b.sort()] = 10;
assert(AA.length == 1);
}
DMD 2.065beta3 gives at run-time:
core.exception.AssertError at test2(9): Assertion failure
My suggestion is to make a SortedRange not hashable (so it gives a compile time
error if you try to use it as associative array key), or implement inside it a
correct hash protocol.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list