digitalmars.D.bugs - [Issue 12140] New: SortedRange as associative array keys
- d-bugmail puremagic.com (32/32) Feb 12 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12140
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 puremagic.com ReportedBy: bearophile_hugs eml.cc 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 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: -------
Feb 12 2014