I am getting a compile error ‘Ambiguous overloaded call to …’ for no apparent reason. This seems to be a bug in Delphi 6. What is the scope of this bug? Does it only affect functions with ‘array of’ parameters? Has it been fixed in newer versions of Delphi?
// This is a simple example to produce the compiler error, not a real program.
function ShowInt(const a: array of string; const i: longint): string; overload;
begin
Result := 'Longint ' + IntToStr(i);
end;
function ShowInt(const a: array of string; const i: int64): string; overload;
begin
Result := 'Int64 ' + IntToStr(i);
end;
procedure Test;
var
i64: int64;
ilong: longint;
begin
ShowInt([], i64 ); // In D6 why does this line compile OK, but next line gives
ShowInt([], ilong); // compile error: Ambiguous overloaded call to 'ShowInt'.
end; // And if the array parameter is removed it compiles OK.
This is a compiler bug and it has been fixed in D2009.