Bug 12108 – Array comparison throws 'TypeInfo.equals is not implemented'

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-08T08:14:08Z
Last change time
2018-11-02T11:26:44Z
Assigned to
No Owner
Creator
Stanislav Blinov

Comments

Comment #0 by stanislav.blinov — 2014-02-08T08:14:08Z
When struct's member field's type has non-const opEquals defined, comparing arrays of these structs throws an exception with not very helpful error message. struct A { bool opEquals(A s) { return false; } } struct B { A a; } void main(){ A a1, a2; if (a1 == a2) {} //ok if ([a1] == [a2]) {} //ok B b1, b2; if (b1 == b2) {} //ok if ([b1] == [b2]) {} // throws object.Error: TypeInfo.equals is not implemented } Making opEquals const gets rid of the exception. It's not clear why it happens at runtime as opposed to compile time, and the message doesn't really explain what's going on.
Comment #1 by stanislav.blinov — 2018-11-02T11:26:44Z
Revisiting older reports; this issue is no longer present in 2.082.1. Closing as WORKSFORME.