Bug 6227 – Comparison of different enums

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-29T17:06:51Z
Last change time
2017-08-16T13:22:48Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-06-29T17:06:51Z
I think comparisons of different enums may hide bugs (this compiles with no errors on DMD 2.053): enum Foo { x } enum Bar { y } void main() { auto b = Foo.x == Bar.y; } A less visible to spot case: enum { X } enum { Y } void main() { auto b = X == Y; } See also bug 3999
Comment #1 by andrej.mitrovich — 2013-01-10T14:59:00Z
*** Issue 8157 has been marked as a duplicate of this issue. ***
Comment #2 by bitter.taste — 2017-01-15T12:51:31Z
Comment #3 by andrei — 2017-05-20T16:54:20Z
With https://github.com/dlang/phobos/pull/5401 the recommended approach is: Foo.x.asOriginalType == Bar.y.asOriginalType i.e. compare the underlying types if that's what's needed. The plan is to fix this bug by deprecating the current behavior. The error message will recommend using asOriginalType.
Comment #4 by github-bugzilla — 2017-05-23T05:13:50Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/c550b03800c0a5aee05820a97cb4da4ad1472eec Fix issue 6227 - Deprecate comparison of different enums https://github.com/dlang/dmd/commit/00b99a2fa2a43ecd4c9d8931a307bb550b4cc3ce Merge pull request #6821 from UplinkCoder/b6227 Fix issue 6227 - Deprecate comparison of different enums (revamp) merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #5 by github-bugzilla — 2017-06-27T22:13:21Z
Commits pushed to master at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/a89e677820f4ce16d4645a153884b824870e4820 Deprecation: Issue 6227 - Comparison of different enums https://github.com/dlang/dlang.org/commit/d91842970a436d714b425a97e835e899d69ffd97 Merge pull request #1673 from wilzbach/deprecate-enum-comparison Deprecation: Issue 6227 - Comparison of different enums merged-on-behalf-of: Vladimir Panteleev <[email protected]>
Comment #6 by github-bugzilla — 2017-08-07T13:16:16Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/c550b03800c0a5aee05820a97cb4da4ad1472eec Fix issue 6227 - Deprecate comparison of different enums https://github.com/dlang/dmd/commit/00b99a2fa2a43ecd4c9d8931a307bb550b4cc3ce Merge pull request #6821 from UplinkCoder/b6227
Comment #7 by github-bugzilla — 2017-08-14T23:55:44Z
Commits pushed to newCTFE at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/a89e677820f4ce16d4645a153884b824870e4820 Deprecation: Issue 6227 - Comparison of different enums https://github.com/dlang/dlang.org/commit/d91842970a436d714b425a97e835e899d69ffd97 Merge pull request #1673 from wilzbach/deprecate-enum-comparison
Comment #8 by github-bugzilla — 2017-08-16T13:22:48Z
Commits pushed to stable at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/a89e677820f4ce16d4645a153884b824870e4820 Deprecation: Issue 6227 - Comparison of different enums https://github.com/dlang/dlang.org/commit/d91842970a436d714b425a97e835e899d69ffd97 Merge pull request #1673 from wilzbach/deprecate-enum-comparison