https://d.puremagic.com/issues/show_bug.cgi?id=5835
Denis Shelomovskij <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |[email protected] Summary|Class array's |`TypeInfo_Array.getHash` |TypeInfo.getHash doesn't |creates raw data hash |work correctly |instead using array element | |hash function --- Comment #5 from Denis Shelomovskij <[email protected]> 2014-03-06 13:57:36 MSK --- Simplified original testcase: --- class S { int i; this(in int i) { this.i = i; } override hash_t toHash() { return 0; } } void main() { S[] a1 = [new S(11)], a2 = [new S(12)]; assert(typeid(S[]).getHash(&a1) == typeid(S[]).getHash(&a2)); // fails } --- With structs: --- struct S { int i; hash_t toHash() const @safe nothrow { return 0; } } void main() { S[] a1 = [S(11)], a2 = [S(12)]; assert(typeid(S[]).getHash(&a1) != typeid(S[]).getHash(&a2)); // fails } --- Associative arrays are affected too because of this: --- struct S { int i; hash_t toHash() const @safe nothrow { return 0; } bool opEquals(ref const S el) const { return true; } int opCmp(ref const S el) const { return 0; } } void main() { int[S[]] aa = [[S(11)] : 13]; assert([S(12)] in aa); // fails } --- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
