Foo Foo = new Foo();

FeepingCreature feepingcreature at gmail.com
Sun Feb 21 18:09:29 UTC 2021


On Sunday, 21 February 2021 at 18:07:49 UTC, JN wrote:
> class Foo
> {
> }
>
> void main()
> {
>     Foo Foo = new Foo();
> }
>
> this kind of code compiles. Is this expected to compile?

Yes, why wouldn't it? main is a different scope than global; you 
can override identifiers from global in main. And "Foo" only 
exists after the declaration, so it doesn't conflict.


More information about the Digitalmars-d-learn mailing list