Thread overview
[Issue 14728] Problems in the switch statement with enumerated data types
Jun 23, 2015
Vladimir Panteleev
Dec 15, 2017
Ali Ak
Dec 15, 2017
Seb
June 23, 2015
https://issues.dlang.org/show_bug.cgi?id=14728

Vladimir Panteleev <thecybershadow@gmail.com> changed:

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

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Here "," is the comma operator, which works as in C (i.e. the first expression is evaluated but its result is discarded). It is the same situation as e.g.

if (x, y) { ... }

The compiler should probably warn that the expression "x" has no side effects.

--
June 23, 2015
https://issues.dlang.org/show_bug.cgi?id=14728

--- Comment #2 from dennis.m.ritchie@mail.ru ---
(In reply to Vladimir Panteleev from comment #1)
> Here "," is the comma operator, which works as in C (i.e. the first expression is evaluated but its result is discarded). It is the same situation as e.g.
> 
> if (x, y) { ... }
> 
> The compiler should probably warn that the expression "x" has no side effects.

Yes, probably, it would be nice if the compiler warns about this.

But I see the second problem. Why is it compiled?

int x = 1;
int y = 2;

but it is not compiled into a switch statement? I think that this option should also be compiled:

int x = 1;
long y = 2;

--
June 23, 2015
https://issues.dlang.org/show_bug.cgi?id=14728

dennis.m.ritchie@mail.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dennis.m.ritchie@mail.ru

--
December 15, 2017
https://issues.dlang.org/show_bug.cgi?id=14728

Ali Ak <ali.akhtarzada@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ali.akhtarzada@gmail.com

--- Comment #3 from Ali Ak <ali.akhtarzada@gmail.com> ---
As of dmd v2.077.1 both scenarios compile and you get a "Deprecation: Using the result of a comma expression is deprecated"

Mark as FIXED?

--
December 15, 2017
https://issues.dlang.org/show_bug.cgi?id=14728

Seb <greensunny12@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |greensunny12@gmail.com
         Resolution|---                         |FIXED

--- Comment #4 from Seb <greensunny12@gmail.com> ---
> Mark as FIXED?

Yes I think so. Otherwise please reopen.
Btw it's since 2.074.1, see https://run.dlang.io/is/W3Ms3E (the All mode tests
the code sample against all D compilers and shows a summary).

--