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



--- Comment #6 from Dmitry Olshansky <dmitry.o...@gmail.com> 2012-04-06 
11:37:01 PDT ---
(In reply to comment #5)
> This compiles with no warnings and it seems to work correctly, but I don't
> fully understand it:
> 
> 
> import core.stdc.stdio: printf;
> template TypeTuple(TList...) {
>     alias TList TypeTuple;
> }
> void main() {
>     char c = 'b';
>     MySwitch: switch (c) {
>         case 'a': printf("1 a\n"); break;
>         foreach (o; TypeTuple!('b', 'c')) {
>             case o: printf("2 %c\n", c); break;
>         }
>         break;
>         default: printf("default");
>     }
> }
> 
> 
> Is it correct? if the break inside here is meant to be the foreach break:

Yes.

> { case o: printf("2 %c\n", c); break; }
No it's {case 0: printf("2 %c\n", c); }

the break did his job already, it can't work twice.


> 
> Then why a single break is enough after:
> 
>         foreach (o; TypeTuple!('b', 'c')) {
>             case o: printf("2 %c\n", c); break;
>         }

Then the code below gives you one break after that statement.
>         break;
> 
> despite the foreach synthesizes more than one switch case?

foreach synthesizes exactly one statement here.

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

Reply via email to