digitalmars.D.bugs - [Issue 7358] New: `final switch` over enum should add throwing default in debug mode at least
- d-bugmail puremagic.com (39/40) Jan 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7358
- d-bugmail puremagic.com (12/12) Jan 31 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7358
- d-bugmail puremagic.com (13/14) Feb 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7358
- d-bugmail puremagic.com (13/13) Oct 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7358
- d-bugmail puremagic.com (9/9) Oct 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7358
http://d.puremagic.com/issues/show_bug.cgi?id=7358 Summary: `final switch` over enum should add throwing default in debug mode at least Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com --- Comment #0 from Denis <verylonglogin.reg gmail.com> 2012-01-24 14:52:00 MSK --- Inspired by bug 5713, comment 5 Even if every enum member is present a default statement should be added at least in debug mode to catch such situation if enum members doesn't cover every possible value: --- enum E { a = 1, b } void f(E e) { final switch (e) { case E.a: case E.b: } } void g() { f(E.a | E.b); // like `f(cast(E)3);`, should throw } --- As was written in bug 5713 description:The purpose of "final switch" is to increase code safety compared to normal switches on enums.So it's really bad that it works silently incorrect. Personally I have used `final switch` carefully and thought about it's behavior in such situation since it has been introduced because it is undocumented. So the documentation should be fixed too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7358 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |yebblies gmail.com AssignedTo|nobody puremagic.com |yebblies gmail.com --- Comment #1 from yebblies <yebblies gmail.com> 2012-02-01 16:09:02 EST --- https://github.com/D-Programming-Language/dmd/pull/673 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 31 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7358 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #2 from bearophile_hugs eml.cc 2012-02-05 06:14:36 PST --- (In reply to comment #1)https://github.com/D-Programming-Language/dmd/pull/673I don't like it. There are better solutions, like: is(typeof(E.a | E.b) == int) This means f(E.a | E.b) becomes a compile-time error, a type mismatch. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7358 --- Comment #4 from github-bugzilla puremagic.com 2012-10-30 07:42:24 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b9ad0b8517c23fa4deca3ddb433dfbb0fab8fb65 Issue 7358 - final switch over enum should add throwing default in debug mode at least Add a throwing default case when compiled with asserts on. https://github.com/D-Programming-Language/dmd/commit/638d81d792d5f12c887de3da6ab00c07d9f227b2 Merge pull request #673 from yebblies/issue7358 Issue 7358 - final switch over enum should add throwing default in debug mode -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7358 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 30 2012