HomeDelphiDelphi Error – E2007 Constant or type identifier expected

Delphi Error – E2007 Constant or type identifier expected

Delphi Compiler Error

E2007 Constant or type identifier expected

Reason for the Error & Solution

This error message occurs when the compiler expects a type, but finds a symbol that is neither a constant (a constant could start a subrange type), nor a type identifier.

program Produce;
var
  c : ExceptionClass; (*ExceptionClass is a variable in System*)
begin
end.

Here, ExceptionClass is a variable, not a type.

program Solve;
program Produce;
var
  c : Exception; (*Exception is a type in SysUtils*)
begin
end.

You need to make sure you specify a type. Maybe the identifier is misspelled, or it is hidden by some other identifier, for example from another unit.

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