Delphi Error – E2050 Statements not allowed in interface part

Delphi Compiler Error

E2050 Statements not allowed in interface part

Reason for the Error & Solution

The interface part of a unit can only contain declarations, not statements.

Move the bodies of procedures to the implementation part.

unit Produce;

interface

procedure MyProc;
begin                (*<-- Error message here*)
end;

implementation

begin
end.

We got carried away and gave MyProc a body right in the interface section.

unit Solve;

interface

procedure MyProc;

implementation

procedure MyProc;
begin
end;

begin
end.

We need move the body to the implementation section – then it’s fine.

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