Delphi Error – E2029 %s expected but %s found

Delphi Compiler Error

E2029 %s expected but %s found

Reason for the Error & Solution

This error message appears for syntax errors. There is probably a typo in the source, or something was left out. When the error occurs at the beginning of a line, the actual error is often on the previous line.

program Produce;
var
  I: Integer
begin               (*<-- Error message here: ';' expected but 'BEGIN' found*)
end.

After the type Integer, the compiler expects to find a semicolon to terminate the variable declaration. It does not find the semicolon on the current line, so it reads on and finds the ‘begin’ keyword at the start of the next line. At this point it finally knows something is wrong…

program Solve;
var
  I: Integer;       (*Semicolon was missing*)
begin
end.

In this case, just the semicolon was missing – a frequent case in practice. In general, have a close look at the line where the error message appears, and the line above it to find out whether something is missing or misspelled.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

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