View mode: basic / threaded / horizontal-split · Log in · Help
August 21, 2010
re: Scope/block behaviour
> 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
August 21, 2010
Re: Scope/block behaviour
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
Top | Discussion index | About this forum | D home