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.
Comment #1 by bugzilla — 2018-05-14T21:40:47Z
Comment #2 by github-bugzilla — 2018-05-15T06:05:00Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/eabc6a62b1d2f5924637f1e61464b9a975341dd4 fix Issue 18858 - switch 'skips declaration' test only checks last declaration https://github.com/dlang/dmd/commit/97876ca3b91c2c70da6d1c63cc3d7246bed81663 Merge pull request #8246 from WalterBright/fix18858 fix Issue 18858 - switch 'skips declaration' test only checks last de…