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

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

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