Docs: Section on local variables

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Apr 25 13:12:02 PDT 2012


On 4/25/12, Stewart Gordon <smjg_1998 at yahoo.com> wrote:
> So you think that
>
> import std.stdio;
> void main() {
>      int a, b;
>      a + b;
>      return;
>      writefln("Hello, world!");
> }
>
> should generate no errors or warnings whatsoever?

I'm really only talking about:
void a() {
int x;
}

And of course:
void a() {
bool state;
...
if (state) { }
}

I'd like the warnings to be individually selectable, just like in GCC.

Btw, here's a trick question, should the compiler warn about this case?

void main() {
    new Foo();  // or even Foo foo = new Foo;
}

:p


More information about the Digitalmars-d-learn mailing list