From a89e677820f4ce16d4645a153884b824870e4820 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Wed, 7 Jun 2017 00:33:38 +0200 Subject: [PATCH 1/2] Deprecation: Issue 6227 - Comparison of different enums --- deprecate.dd | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/deprecate.dd b/deprecate.dd index 784871a84d..752767bed6 100644 --- a/deprecate.dd +++ b/deprecate.dd @@ -10,6 +10,7 @@ $(SPEC_S Deprecated Features, $(TABLE2 Deprecated Features, $(THEAD Feature, Spec, Dep, Error, Gone) + $(TROW $(DEPLINK Implicit comparison of different enums), 2.075, 2.075,  ,  ) $(TROW $(DEPLINK Implicit string concatenation), 2.072, 2.072,  ,  ) $(TROW $(DEPLINK Using the result of a comma expression), 2.072, 2.072,  ,  ) $(TROW $(DEPLINK delete), future,  ,  ,  ) @@ -57,6 +58,41 @@ $(SPEC_S Deprecated Features, $(DD The feature is completely gone) ) +$(H3 $(DEPNAME Implicit comparison of different enums)) + $(P Currently, comparison of different enumerated type is allowed: + --- + enum Status + { + good, + bad + } + enum OtherStatus + { + ok + no, + } + static assert(Status.good == OtherStatus.ok); + --- + ) +$(H4 Corrective Action) + $(P Comparison between unrelated enumerated types should be done with $(REF asOriginalType, std, conv)) + --- + import std.conv : asOriginalType; + assert(Foo.x.asOriginalType == Bar.y.asOriginalType); + --- +$(H4 Rationale) + $(P Code correctness is improved by + disallowing comparison of unrelated enumerated types. Implicit comparison of + different `enum` types often resulted in hard to spot bugs.) + + --- + enum { X } + enum { Y } + void main() { + auto b = X == Y; + assert(b); + } + --- $(H3 $(DEPNAME Implicit string concatenation)) $(P Currently, two adjacent strings are implicitly concatenated: From 007c450ae4a9531467914d89b998f8d8c703ded4 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 27 Jun 2017 23:57:09 +0200 Subject: [PATCH 2/2] Set intro of the enum and implict string concatenation deprecation entry to the past --- deprecate.dd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deprecate.dd b/deprecate.dd index 752767bed6..4525ddd21f 100644 --- a/deprecate.dd +++ b/deprecate.dd @@ -59,7 +59,7 @@ $(SPEC_S Deprecated Features, ) $(H3 $(DEPNAME Implicit comparison of different enums)) - $(P Currently, comparison of different enumerated type is allowed: + $(P Comparison of different enumerated type was allowed: --- enum Status { @@ -95,14 +95,14 @@ $(H4 Rationale) --- $(H3 $(DEPNAME Implicit string concatenation)) - $(P Currently, two adjacent strings are implicitly concatenated: + $(P Two adjacent strings were implicitly concatenated: --- string foo = "Hello" "World"; --- - This feature is handy for a long string that spans multiple lines, - however it is possible to get the same behaviour explicitly by + This feature was handy for a long string that spans multiple lines, + however, it is possible to get the same behaviour explicitly by using the concatenation operator ('~'): ---