Bug 16578 – bogus deprecation - switch skips declaration of variable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-02T22:39:54Z
Last change time
2018-03-03T16:19:20Z
Keywords
pull
Assigned to
No Owner
Creator
Martin Krejcirik
See also
https://issues.dlang.org/show_bug.cgi?id=17752

Comments

Comment #0 by mk — 2016-10-02T22:39:54Z
string[string] opts; void main() { string arg; switch (arg) { case "-f": opts["fore"] = ""; break; debug { case "-throw": opts["throw"] = ""; break; } default: } } bug.d(6): Deprecation: 'switch' skips declaration of variable bug.main.__aaval51 at bug.d(8) dmd 2.072 b1 compile with -debug Related pull: Pull https://github.com/dlang/dmd/pull/5869
Comment #1 by greensunny12 — 2018-02-11T02:22:44Z
The problem seems to be due to the associative array. Reduced a bit further: --- import std.stdio; void main() { string[string] opts; switch (2) { case 0: opts["a"] = ""; { case 1: break; } default: } } ---
Comment #2 by slavo5150 — 2018-02-14T11:58:56Z
Comment #3 by github-bugzilla — 2018-03-03T16:19:19Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/8515ae6a0b2b20845f2f5aa095bfc57df12fcc93 Fix Issue 16578 - bogus deprecation - switch skips declaration of variable https://github.com/dlang/dmd/commit/65bc40805dd61d4c888cc7ab87794cc91c1e0991 Merge pull request #7891 from JinShil/fix_16578 Fix Issue 16578 - bogus deprecation - switch skips declaration of variable merged-on-behalf-of: Jacob Carlborg <[email protected]>