Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1521 from AndrejMitrovic/Fix9358

Issue 9358 - Compiler creates duplicate switch cases on error
  • Loading branch information...
commit 3e3d8f8fdc478c80190be8a25d1e7a6ea1d9c79d 2 parents a2d0e64 + f8b9943
@yebblies yebblies authored
Showing with 19 additions and 1 deletion.
  1. +1 −1  src/statement.c
  2. +18 −0 test/fail_compilation/diag9358.d
View
2  src/statement.c
@@ -3402,7 +3402,7 @@ Statement *CaseStatement::semantic(Scope *sc)
if (exp->op != TOKstring && exp->op != TOKint64 && exp->op != TOKerror)
{
error("case must be a string or an integral constant, not %s", exp->toChars());
- exp = new IntegerExp(0);
+ exp = new ErrorExp();
}
L1:
View
18 test/fail_compilation/diag9358.d
@@ -0,0 +1,18 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/diag9358.d(12): Error: 'x' must be of integral or string type, it is a double
+fail_compilation/diag9358.d(14): Error: case must be a string or an integral constant, not 1.1
+fail_compilation/diag9358.d(15): Error: case must be a string or an integral constant, not 2.1
+---
+*/
+void main()
+{
+ double x;
+ switch (x)
+ {
+ case 1.1: break;
+ case 2.1: break;
+ default:
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.