Compiler doesn't complain about overloaded functions with same arguments if their result types differ
Original Reporter info from Mantis: Hixie
-
Reporter name: Ian Hickson
Original Reporter info from Mantis: Hixie
- Reporter name: Ian Hickson
Description:
Consider:
{$MODE OBJFPC}
program overloaddemo;
function Test(const Value: Double): AnsiString;
begin
Result := '';
end;
function Test(const Value: Double): Double;
begin
Result := 0.0;
end;
var
S: AnsiString;
D: Double;
begin
S := Test(1.0);
D := Test(1.0); // error
end.
This won't compile, because on the line marked "error", the compiler correctly surmises that Test() returns an AnsiString, not a Double, but D is of type Double, so you get "Incompatible types: got "AnsiString" expected "Double"".
However. It shouldn't ever get that far. We should get the error "overloaded functions have the same parameter list" on the second definition of the function Test(), just as we would if we changed the second declaration to match the first.
Mantis conversion info:
- Mantis ID: 24606
- Build: 2.7.1 [2013/06/02] for x86_64
- Platform: x64
- Version: 2.7.1