[Issue 15828] DMD should refuse comparing unions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 29 09:04:17 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=15828

Simon Na. <eiderdaus at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eiderdaus at gmail.com

--- Comment #3 from Simon Na. <eiderdaus at gmail.com> ---
I agree that implicitly comparing unions should be a compiler error.

The spec doesn't mention == for unions at all:
https://dlang.org/spec/expression.html#compare_expressions

The failure to call opEquals on a class reference in the union caused
https://issues.dlang.org/show_bug.cgi?id=18615
Rebindable!A doesn't use class A's opEquals (returns a is b instead).

I've submitted a PR for Phobos to fix 18615 by explicitly comparing the class
references in Rebindable's union:
https://github.com/dlang/phobos/pull/6370

I hope that such removal of implicit union comparision eases the pain of fixing
this 15828. :-)

--


More information about the Digitalmars-d-bugs mailing list