Delphi Error – E2182 ‘%s’ clause not allowed in OLE automation section

Delphi Compiler Error

E2182 ‘%s’ clause not allowed in OLE automation section

Reason for the Error & Solution

INDEX, STORED, DEFAULT and NODEFAULT are not allowed in OLE automation sections.

program Produce;

  type
     Base = class
       v : integer;
       procedure setV(x : integer);
       function getV : integer;
       automated
       property Value : integer read getV write setV nodefault;
     end;

  procedure Base.setV(x : integer);
  begin v := x;
  end;

  function Base.getV : integer;
  begin getV := v;
  end;

begin
end.

Including a NODEFAULT clause on an automated property is not allowed.

program Solve;

  type
     Base = class
       v : integer;
       procedure setV(x : integer);
       function getV : integer;
       automated
       property Value : integer read getV write setV;
     end;

  procedure Base.setV(x : integer);
  begin v := x;
  end;

  function Base.getV : integer;
  begin getV := v;
  end;

begin
end.

Removing the offending clause will cause the error to go away. Alternatively, moving the property out of the automated section will also make the error go away.

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