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.