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.