HomeDelphiDelphi Error – E2050 Statements not allowed in interface part

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

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