Ad Space — Top Banner

E2046

Delphi Programming Language

Severity: Moderate

What Does This Error Mean?

E2046 means Delphi found a syntax error because a semicolon is missing where one is required. In Delphi, semicolons separate statements — they are needed between statements but not before END or ELSE. Fix it by adding the missing semicolon at the end of the statement the IDE highlights.

Affected Models

  • Delphi 10.4 Sydney
  • Delphi 11 Alexandria
  • Delphi 12 Athens
  • Embarcadero RAD Studio
  • Free Pascal / Lazarus

Common Causes

  • Forgetting a semicolon at the end of a statement before a new statement
  • Missing semicolon at the end of a variable or type declaration
  • Omitting the semicolon after a function or procedure declaration in the interface section
  • Missing semicolon after a uses clause entry
  • Forgetting the semicolon that separates statements inside a begin...end block

How to Fix It

  1. Look at the line before the error location — the missing semicolon is usually at the end of the previous statement, not on the highlighted line.

    Delphi reports the error where it notices the problem, but the missing semicolon is often one line earlier.

  2. Add a semicolon at the end of the statement before the highlighted position.

    Most Delphi statements end with a semicolon: variable assignments, procedure calls, declarations in the interface section.

  3. Remember that in Delphi, semicolons are statement separators, not terminators — you do NOT need a semicolon immediately before END or immediately before ELSE.

    Writing X := 1; end; or X := 1; else are not errors, but the semicolon before ELSE is also not needed and some would consider it style preference.

  4. Check the uses clause — each unit name in a uses clause is separated by a comma, and the entire clause ends with a semicolon.

    Example: uses SysUtils, Classes, Controls; — the semicolon is at the end of the list, not after each name.

  5. In the interface section, every type, constant, variable, and procedure/function declaration must end with a semicolon.

    Example: procedure DoSomething(Value: Integer); — the semicolon at the end is required in the declaration.

When to Call a Professional

This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.

Frequently Asked Questions

Why does the error appear on a different line from where the semicolon is missing?

The Delphi compiler reads the file sequentially and reports the error where it first notices that something is wrong. If a semicolon is missing at the end of line 10, the compiler may not realize this until it reads line 11 and finds unexpected content. Always look at the line before the highlighted error location for the missing semicolon.

When should I NOT put a semicolon in Delphi?

Do not put a semicolon between the last statement inside a begin...end block and the END keyword — it is optional there. Do not put a semicolon between a statement and the ELSE keyword in an if statement. Do not put a semicolon between the THEN and the following statement in a single-line if.

Are there other common syntax errors similar to E2046?

Yes — Delphi also reports errors for missing colons in type declarations, missing BEGIN keywords, missing END keywords, and missing parentheses. These all fall under the general category of syntax errors and are fixed by adding the missing punctuation. The Delphi IDE Code Insight feature (Ctrl+Space) can sometimes help identify where syntax is incorrect.