Overload in constructor with incompatible arguments should cause a compler error

Constructor Create(s: String; b: String = "");
Constructor Create(s: String; q: String);

Th above compiles without error

hmm, indeed it should not. can i get a complete testcase? thanx!

The test case:

namespace Test;

interface

type SafeString = unit not nullable String; //alias for not nullable string

type TestClass = public class
  public
//2 or 3 arguments
    Constructor Create(Server: SafeString; Db: SafeString; conId: String = "NoId"); begin end;
//3 or 4 arguments
    Constructor Create(Server: SafeString; Mirror: SafeString; Db: SafeString; conId: String = "NoId"); begin end;
//4 or 5 arguments
    Constructor Create(Server: SafeString; Db: SafeString; UserName: SafeString; Password: SafeString; conId: String = "NoId"); begin end;
//5 or 6 arguments
    Constructor Create(Server: SafeString; Mirror: SafeString; Db: SafeString; UserName: SafeString; Password: SafeString; conId: String = "NoId"); begin end;


end;

Implementation

end.

Thanks, logged as bugs://82160

bugs://82160 got closed with status nochangereq.

Oke so this is tricky; these are not actually the same, however I agree the default parameters can’t really be called. the compiler will always prefer fewer parameters to more parameters. The reason we don’t fail on this is because a C# caller CAN call these with named arguments and still use the default argument like:

new TestClass(Server: “”, Db: “”, Mirror: “”) << calls the second overload.

So I fear I have to close this as “can’t fix”.

woah, I didn’t know C# supports this!

VB.Net does too.
Hint: may be something for Oxygene?

Can I get a warning on it?