Scope/block behaviour

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Aug 21 00:08:39 PDT 2010


On 08/21/2010 01:21 AM, Eduardo Cavazos wrote:
>
>  > void main ()
>  > {
>  > { int f0 () { return 10 ; } }
>  >
>  > { int f0 () { return 20 ; } }
>  > }
>
> Stewart Gordon wrote:
>
>  > Looks like a bug.
>
> The compiler recognizes the situation and reports it as an error, so it
> seems like this is not a bug, but something which is not supported:
>
> ~/scratch $ rdmd test_scope_a.d
> test_scope_a.d(6): Error: declaration f0 is already defined in
> another scope in main
>
> The rationale in TDPL that Andrei pointed to doesn't seem to cover the
> case above.
>
> Can anyone confirm that the above really is against the rules of the
> language?
>
> Ed

I think it is a bug. Technically I understand it - Walter names inner 
functions like main.f0, which does not leave room for functions with the 
same name inside the same function. Shouldn't be difficult to fix 
though. Mind submitting a bug report please?

Andrei


More information about the Digitalmars-d mailing list