[Issue 15535] Emit error on "goto default" in final switch

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jan 9 13:43:36 PST 2016


https://issues.dlang.org/show_bug.cgi?id=15535

--- Comment #1 from Johan Engelen <goejendaagh at zonnet.nl> ---
(This is probably mostly a note to self.)

Note that "goto default" means to go to the default label of the current switch
statement only. So this does not work:

void main()
{
    int i = 1;
    switch (i) {
        case 1:
            final switch(i) {
                case 1: goto default;
            }
        default:
            i = 666;
            break;
    }
    assert(i == 666);
}

The code compiles and when run will throw
core.exception.SwitchError at gotodefault(6): No appropriate switch clause found
(line 6 contains the "goto default")

--


More information about the Digitalmars-d-bugs mailing list