Delphi Error – E2132 Default property must be an array property

Delphi Compiler Error

E2132 Default property must be an array property

Reason for the Error & Solution

The default property which you have specified for the class is not an array property. Default properties are required to be array properties.

program Produce;

  type
    Base = class
      function GetV : Char;
      procedure SetV(x : Char);

      property Data : Char read GetV write SetV; default;
    end;

  function Base.GetV : Char;
  begin GetV := 'A';
  end;

  procedure Base.SetV(x : Char);
  begin
  end;

begin
end.

When specifying a default property, you must make sure that it conforms to the array property syntax. The ‘Data’ property in the above code specifies a ‘Char’ type rather than an array.

program Solve;

  type
    Base = class
      function GetV(i : Integer) : Char;
      procedure SetV(i : Integer; const x : Char);

      property Data[i : Integer] : Char read GetV write SetV; default;
    end;

  function Base.GetV(i : Integer) : Char;
  begin GetV := 'A';
  end;

  procedure Base.SetV(i : Integer; const x : Char);
  begin
  end;

begin
end.

By changing the specification of the offending property to an array, or by removing the ‘default’ directive, you can remove this error.

Share:

Leave A Reply

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

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