This program produces a runtime assert error, it's a bug: struct Foo { string s; } void main() { Foo b1 = Foo("hello".idup); Foo b2 = Foo("hello".idup); assert(b1 !is b2); // OK assert(b1 == b2); // line 8, error } With DMD 2.056head it gives: core.exception.AssertError@test(8): Assertion failure The equality among structs has to call the string equality of their fields. The "is" operator has to compare the structs bitwise.
Class type has same problem. struct Foo { string s; } struct Bar { static class X { bool opEquals(Object o){ return true; } } X x; } void main() { Foo f1 = Foo("hello".idup); Foo f2 = Foo("hello".idup); assert(f1 !is f2); // OK assert(f1 == f2); // error Bar b1 = Bar(new Bar.X()); Bar b2 = Bar(new Bar.X()); assert(b1 !is b2); // OK assert(b1 == b2); // error! }
Looks like a dup of bug 3789
*** This issue has been marked as a duplicate of issue 3789 ***