Delphi Error – E2251 Ambiguous overloaded call to ‘%s’

Delphi Compiler Error

E2251 Ambiguous overloaded call to ‘%s’

Reason for the Error & Solution

Based on the current overload list for the specified function, and the programmed invocation, the compiler is unable to determine which version of the procedure should be invoked.

program Produce;

procedure f0(a : integer); overload;
begin
end;

procedure f0(a : integer; b : char = 'A'); overload;
begin
end;

begin
  f0(1);
end.

In this example, the default parameter that exists in one of the versions of f0 makes it impossible for the compiler to determine which procedure should actually be called.

program Solve;

procedure f0(a : integer); overload;
begin
end;

procedure f0(a : integer; b : char); overload;
begin
end;

begin
  f0(1);
end.

The approach taken in this example was to remove the default parameter value. The result here is that the procedure taking only one integer parameter will be called. It should be noted that this approach is the only way that the single-parameter function can be called.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...