E2268 Parameters of this type cannot have default values (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

The default parameter mechanism incorporated into the Delphi compiler allows only simple types to be initialized in this manner. You have attempted to use a type that is not supported.


program Produce;
type
  ArrayType = array [0..1] of integer;

  procedure p1(proc : ArrayType = [1, 2]);
  begin
  end;
end.


Default parameters of this type are not supported in the Delphi language.


program solve;
type
  ArrayType = array [0..1] of integer;

  procedure p1(proc : ArrayType);
  begin
  end;

end.


The only way to eliminate this error is to remove the offending parameter assignment or to change the type of the parameter to one that can be initialized with a default value.