HomeDelphiDelphi Error – E2237 Parameter ‘%s’ not allowed here due to default value

Delphi Error – E2237 Parameter ‘%s’ not allowed here due to default value

Delphi Compiler Error

E2237 Parameter ‘%s’ not allowed here due to default value

Reason for the Error & Solution

When using default parameters a list of parameters followed by a type is not allowed; you must specify each variable and its default value individually.

program Produce;

  procedure p0(a, b : Integer = 151);
  begin
  end;

begin
end.

The procedure definitions shown above will cause this error since it declares two parameters with a default value.

program Solve;

  procedure p0(a : Integer; b : Integer = 151);
  begin
  end;

  procedure p1(a : Integer = 151; b : Integer = 151);
  begin
  end;

begin
end.

Depending on the desired result, there are different ways of approaching this problem. If only the last parameter is supposed to have the default value, then take the approach shown in the first example. If both parameters are supposed to have default values, then take the approach shown in the second example.

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...