Duplicated functions not reported?

Stefan Koch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 15 04:10:01 PDT 2017


On Saturday, 15 April 2017 at 09:17:08 UTC, Jacob Carlborg wrote:
> I'm not sure if I'm missing something obvious here, but the 
> following code compiles and runs:
>
> void foo() {}
> void foo() {}
>
> void main() {}
>
> Although if I do call "foo", the compiler will complain that it 
> matches both versions of "foo".
>
> Is this expected behavior of how function overloading works? Is 
> it possible to for the compiler to report this error? At least 
> this example is pretty obvious for a human to see.

It would requires an O(n^2) check per declaration.
Even it is never used.
which would make imports that much more expensive.


More information about the Digitalmars-d-learn mailing list