| 1 |
/* |
| 2 |
REQUIRED_ARGS: -verrors=context |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/switch_skip.d(22): Error: `switch` skips declaration of variable `switch_skip.test3.j` |
| 6 |
switch (i) |
| 7 |
^ |
| 8 |
fail_compilation/switch_skip.d(26): declared here |
| 9 |
int j; |
| 10 |
^ |
| 11 |
fail_compilation/switch_skip.d(39): Error: `switch` skips declaration of variable `switch_skip.test.z` |
| 12 |
final switch(n) |
| 13 |
^ |
| 14 |
fail_compilation/switch_skip.d(41): declared here |
| 15 |
int z = 5; |
| 16 |
^ |
| 17 |
--- |
| 18 |
*/ |
| 19 |
|
| 20 |
void test3(int i) |
| 21 |
{ |
| 22 |
switch (i) |
| 23 |
{ |
| 24 |
case 1: |
| 25 |
{ |
| 26 |
int j; |
| 27 |
case 2: |
| 28 |
++j; |
| 29 |
break; |
| 30 |
} |
| 31 |
default: |
| 32 |
break; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
// https://issues.dlang.org/show_bug.cgi?id=18858 |
| 37 |
int test(int n) |
| 38 |
{ |
| 39 |
final switch(n) |
| 40 |
{ |
| 41 |
int z = 5; |
| 42 |
enum e = 6; |
| 43 |
|
| 44 |
case 1: |
| 45 |
int y = 2; |
| 46 |
return y; |
| 47 |
} |
| 48 |
} |