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

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