Bug 3144 – (D1 only) Invalid break accepted

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-07-06T20:55:00Z
Last change time
2012-11-08T09:28:23Z
Keywords
accepts-invalid, pull
Assigned to
yebblies
Creator
tim.matthews7

Comments

Comment #0 by tim.matthews7 — 2009-07-06T20:55:44Z
This break statement causes program to exit: import std.stdio; void main() { int i = 1; switch (i) case 1: writeln("1"); break; writeln("exit"); } It should instead report "Error: break is not inside a loop or switch" like it does for this code: void main() { break; }
Comment #1 by yebblies — 2012-01-29T22:46:39Z
This is a parser bug, from what I can tell. dmd assumes that the statements inside a switch block are terminated with a '}', which isn't the case here.
Comment #2 by yebblies — 2012-01-29T22:53:47Z
Comment #3 by github-bugzilla — 2012-10-27T04:33:52Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c345b379a40280158a31fd041a30b7eb3962bbbf fix Issue 3144 - Invalid break accepted https://github.com/D-Programming-Language/dmd/commit/86a378bc33aa0698e3245a04088449315ae0b852 Merge pull request #1182 from 9rnsr/fix3144 Another fix for Issue 3144 - Invalid break accepted
Comment #4 by yebblies — 2012-10-27T08:27:51Z
Fixed D2
Comment #5 by k.hara.pg — 2012-11-08T09:28:23Z