http://d.puremagic.com/issues/show_bug.cgi?id=6518
Summary: break inside a static foreach inside a switch Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2011-08-17 06:05:15 PDT --- import std.typetuple: TypeTuple; enum Foo : uint { A, B, C } alias TypeTuple!(Foo.A, Foo.B, Foo.C) FooNames; void main() { Foo fo; switch (fo) { /*static*/ foreach (i, op; __traits(allMembers, Foo)) case FooNames[i]: break; default: assert(0); } } test.d(8): Error: switch case fallthrough - use 'goto case;' if intended test.d(8): Error: switch case fallthrough - use 'goto case;' if intended test.d(8): Error: switch case fallthrough - use 'goto case;' if intended test.d(10): Error: switch case fallthrough - use 'goto default;' if intended I think DMD 2.042 doesn't have this problem, this code used to work. I think this problem comes from recent changes in switch switch semantics and analysis. The following code gives the same errors, showing it's not a problem of break breaking the foreach loop (like it probably has to do; so maybe the first example not correct?): import std.typetuple: TypeTuple; enum Foo : uint { A, B, C } alias TypeTuple!(Foo.A, Foo.B, Foo.C) FooNames; void main() { Foo fo; LABEL: switch (fo) { /*static*/ foreach (i, op; __traits(allMembers, Foo)) case FooNames[i]: break LABEL; default: assert(0); } } ---------------- That code is a reduction of a problem found in a recent version of the modified regex module: void parseFlags(S)(S flags) { foreach(ch; flags)//flags are ASCII anyway { switch(ch) { foreach(i, op; __traits(allMembers, RegexOption)) { case RegexOptionNames[i]: if(re_flags & mixin("RegexOption."~op)) throw new RegexException(text("redundant flag specified: ",ch)); re_flags |= mixin("RegexOption."~op); break; } default: if(__ctfe) assert(text("unknown regex flag '",ch,"'")); else new RegexException(text("unknown regex flag '",ch,"'")); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------