Thread overview
[Issue 16549] Switch statement can skip initialization
Sep 27, 2016
Jacob Carlborg
Sep 27, 2016
Jacob Carlborg
Sep 27, 2016
Mathias Lang
Sep 27, 2016
Jacob Carlborg
Sep 27, 2016
Mathias Lang
September 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16549

Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All
           Severity|enhancement                 |major

--
September 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16549

--- Comment #1 from Jacob Carlborg <doob@me.com> ---
Here's a very similar case where it fails to initialize "foo" as well:

import std.stdio;

struct State {}

State bar(int jumpLabel)
{
    switch (jumpLabel)
    {
        int foo;
        case 0:
        writeln(foo);

        default:
        break;
    }

    return State();
}

void main()
{
    auto state = bar(0);
}

--
September 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16549

Mathias Lang <mathias.lang@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mathias.lang@sociomantic.co
                   |                            |m

--- Comment #2 from Mathias Lang <mathias.lang@sociomantic.com> ---
Compiling with master will give you a deprecation message:

lol.d(8): Deprecation: 'switch' skips declaration of variable lol.bar.foo at
lol.d(10)

--
September 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16549

--- Comment #3 from Jacob Carlborg <doob@me.com> ---
(In reply to Mathias Lang from comment #2)
> Compiling with master will give you a deprecation message:
> 
> lol.d(8): Deprecation: 'switch' skips declaration of variable lol.bar.foo at
> lol.d(10)

Ah, yes. Is there a commit to refer to so we can close this. Or is this a duplicate?

--
September 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16549

Mathias Lang <mathias.lang@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Mathias Lang <mathias.lang@sociomantic.com> ---
I'll mark as duplicate. It was fixed by https://github.com/dlang/dmd/pull/5869

*** This issue has been marked as a duplicate of issue 14532 ***

--