Skip to content

Commit

Permalink
Merge pull request #3287 from schuetzm/non_final_switch_hint
Browse files Browse the repository at this point in the history
Give users some guidance on how to handle missing default cases.
  • Loading branch information
WalterBright committed Feb 22, 2014
2 parents 091df98 + c5857b7 commit 88d52ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/statement.c
Expand Up @@ -2899,7 +2899,7 @@ Statement *SwitchStatement::semantic(Scope *sc)
{ hasNoDefault = 1;

if (!isFinal && !body->isErrorStatement())
deprecation("non-final switch statement without a default is deprecated");
deprecation("non-final switch statement without a default is deprecated; add 'default: assert(0);' or 'default: break;'");

// Generate runtime error if the default is hit
Statements *a = new Statements();
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail287.d
Expand Up @@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/fail287.d(14): Error: had 299 cases which is more than 256 cases in case range
fail_compilation/fail287.d(12): Deprecation: non-final switch statement without a default is deprecated
fail_compilation/fail287.d(12): Deprecation: non-final switch statement without a default is deprecated; add 'default: assert(0);' or 'default: break;'
---
*/

Expand Down

0 comments on commit 88d52ff

Please sign in to comment.