This program produces an error: void main () { { int f0 () { return 10 ; } } { int f0 () { return 20 ; } } } $ rdmd test_scope_a.d test_scope_a.d(6): Error: declaration f0 is already defined in another scope in main
Why is this a bug?
*** Issue 5882 has been marked as a duplicate of this issue. ***
Because the two functions named f0 are in disjoint scopes, the compiler shouldn't care about the fact that they have the same name. I can see a problem in that at the moment the mangled names of the two functions would clash. So this is presumably a temporary restriction in the compiler pending a name mangling scheme that avoids this.
(In reply to comment #3) > So this is presumably a temporary restriction in the > compiler pending a name mangling scheme that avoids this. Walter could answer if this restriction is temporary or not.
*** Issue 12881 has been marked as a duplicate of this issue. ***
(In reply to bearophile_hugs from comment #4) > > Walter could answer if this restriction is temporary or not. This is not an intentional limitation, and will be fixed eventually.
*** Issue 4894 has been marked as a duplicate of this issue. ***
This has been fixed. The code compiles with the latest master.