http://d.puremagic.com/issues/show_bug.cgi?id=6518



--- Comment #1 from Kenji Hara <k.hara...@gmail.com> 2011-08-17 16:31:46 PDT ---
(In reply to comment #0)
> 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);
>     }
> }
[snip]
> 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.

This code could compile with trunk dmd (c98b611), and it asserts in run time.
Which version did you try it with?

> 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);
>     }
> }

This code could compile, and it succeeds to run.

I think these behaviors in my PC are correct.
In first sample code, break-statement eacapes from foreach, and always goes
into default case, and asserts.
And in second sample, break-statement escapes from LABEL-ed switch statement.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to