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

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

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...