Bug 18858 – switch 'skips declaration' test only checks last declaration
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-14T20:06:32Z
Last change time
2018-05-15T06:05:01Z
Assigned to
No Owner
Creator
Walter Bright
Comments
Comment #0 by bugzilla — 2018-05-14T20:06:32Z
Consider:
int test(int n)
{
final switch(n)
{
enum e = 6;
int z = 5; // Error: switch skips declaration of variable test.z
case 1:
int y = 2;
return y;
}
}
Good. Now reverse the enum e and int z statements, and no error will be generated.