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

Instead of finding a statement, the compiler discovered an expression of the provided type.

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

The compiler was looking for a statement like an IF, WHILE, or REPEAT in this case, but instead encountered the expression (3+4).

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

The result of the expression (3+4) was assigned to the variable ‘a’ as a solution. Another option would have been to remove the objectionable expression from the source code; the decision would have to be made based on the circumstances.

%d bloggers like this: