Bug 12157 – Variant opEquals always returns false for classes.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-13T22:02:00Z
Last change time
2014-03-15T18:50:05Z
Keywords
pull
Assigned to
opantm2+dbugs
Creator
opantm2+dbugs
Comments
Comment #0 by opantm2+dbugs — 2014-02-13T22:02:00Z
Sample:
import std.variant;
class Foo {
int a;
}
void main() {
Foo f = new Foo();
Variant v = f;
assert(v == f);
}
Because the check for if it's possible checks if typeof T.init == T.init, which is a compiler error for classes as it compares to null.
Comment #1 by opantm2+dbugs — 2014-02-23T21:49:53Z