Delphi Error – E2169 Field definition not allowed after methods or properties

Delphi Compiler Error

E2169 Field definition not allowed after methods or properties

Reason for the Error & Solution

You have attempted to add more fields to a class after the first method or property declaration has been encountered. You must place all field definitions before methods and properties.

program Produce;

  type
    Base = class
      procedure FirstMethod;
      a : Integer;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

The declaration of ‘a’ after ‘FirstMethod’ will cause an error.

program Solve;

  type
    Base = class
      a : Integer;
      procedure FirstMethod;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

To solve this error, it is normally sufficient to move all field definitions before the first field or property declaration.

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