Delphi Error – E2014 Statement expected, but expression of type ‘%s’ found

Delphi Compiler Error

E2014 Statement expected, but expression of type ‘%s’ found

Reason for the Error & Solution

The compiler was expecting to find a statement, but instead it found an expression of the specified type.

  program Produce;
    var
      a : Integer;
  begin
     (3 + 4);
  end.

In this example, the compiler is expecting to find a statement, such as an IF, WHILE, REPEAT, but instead it found the expression (3+4).

  program Produce;
    var
      a : Integer;
  begin
     a := (3 + 4);
  end.

The solution here was to assign the result of the expression (3+4) to the variable ‘a’. Another solution would have been to remove the offending expression from the source code – the choice depends on the situation.

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