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

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

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