digitalmars.D.bugs - [Issue 2155] New: case statements always start new scope
- d-bugmail puremagic.com (43/43) Jun 19 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2155
- d-bugmail puremagic.com (9/9) Jun 20 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2155
http://d.puremagic.com/issues/show_bug.cgi?id=2155 Summary: case statements always start new scope Product: D Version: 1.029 Platform: PC OS/Version: Linux Status: NEW Keywords: spec Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: kamm-removethis incasoftware.de Scope statements introduce a new scope even when not using ScopeBlockStatement, as seen here: switch(1) { case 1: writefln("case 1"); scope(exit) writefln("case 1 scope exit"); case 2: writefln("fallthrough to 2"); } prints: case 1 case 1 scope exit fallthrough to 2 But this behaviour is not described in the spec. Maybe add: "Case statements start a scope that ends at the end of the enclosing scope or before the next case or default statement that is inside the same scope level. Example: switch(i) { case 1: // implicit scope start 1 ... // implicit scope end 1 case 2: // implicit scope start 2 while(true) { case 3: // implicit scope start 3 // implcit scope end 3 } // implicit scope end 2 } " --
Jun 19 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2155 kamm-removethis incasoftware.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE ------- *** This bug has been marked as a duplicate of 603 *** --
Jun 20 2008