Thread overview
[Issue 15828] DMD should refuse comparing unions
Mar 24, 2016
Johannes Pfau
Mar 24, 2016
Iain Buclaw
Mar 29, 2018
Simon Na.
Jul 26, 2021
Teodor Dutu
Jul 30, 2021
Dlang Bot
Dec 17, 2022
Iain Buclaw
March 24, 2016
https://issues.dlang.org/show_bug.cgi?id=15828

--- Comment #1 from Johannes Pfau <johannespfau@gmail.com> ---
Small correction: std.json has already been fixed in upstream phobos, so I can just backport that fix for GDC.

--
March 24, 2016
https://issues.dlang.org/show_bug.cgi?id=15828

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Johannes Pfau from comment #1)
> Small correction: std.json has already been fixed in upstream phobos, so I can just backport that fix for GDC.

Excellent, less work for us to do. :-)

--
March 29, 2018
https://issues.dlang.org/show_bug.cgi?id=15828

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

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

--- Comment #3 from Simon Na. <eiderdaus@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. :-)

--
July 26, 2021
https://issues.dlang.org/show_bug.cgi?id=15828

Teodor Dutu <teodor.dutu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |teodor.dutu@gmail.com
           Assignee|nobody@puremagic.com        |teodor.dutu@gmail.com

--
July 30, 2021
https://issues.dlang.org/show_bug.cgi?id=15828

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@teodutu created dlang/dmd pull request #12937 "[DSSv3] Fix Issue 15828 - DMD should refuse comparing unions" fixing this issue:

- Fix Issue 15828 - DMD should refuse comparing unions

  Changes:
  - Add check in `dmd/opover.d` to verify if the compared structs are
  unions and output an error if the check passes
  - Verify the error by `tests/fail_compilation/test15828.d`
  - Add `changelog/union-comparison.dd` to explain these changes

https://github.com/dlang/dmd/pull/12937

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15828

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--