RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2132: Default property must be an array property (Delphi)

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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!