Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 12, 2011 [Issue 5989] New: Disallow unreachable statements in switch clause | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5989 Summary: Disallow unreachable statements in switch clause Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-12 15:23:13 PDT --- enum State { init, done } void main() { State state; int x; final switch (state) { x = 5; // <- can never reach this statement case State.init: case State.done: } assert(x == 5); // throws } I've run into this while adding some logging to my code. By accident I've added a print statement right above the case statements inside a final switch, and was puzzled why my code didn't want to log out any information. The above code is clearly an error and I think the compiler should disallow or at least warn about the unreachable statement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 12, 2011 [Issue 5989] Disallow unreachable statements in switch clause | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=5989 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2011-05-12 15:31:27 PDT --- Dupe of bug 3820 ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 12, 2011 [Issue 5989] Disallow unreachable statements in switch clause | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=5989 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #2 from bearophile_hugs@eml.cc 2011-05-12 15:33:44 PDT --- *** This issue has been marked as a duplicate of issue 3820 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 12, 2011 [Issue 5989] Disallow unreachable statements in switch clause | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=5989 --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-12 15:37:34 PDT --- Thanks for dupping! :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation