Delphi Error – E2001 Ordinal type required

Delphi Compiler Error

E2001 Ordinal type required

Reason for the Error & Solution

The compiler required an ordinal type at this point. Ordinal types are the predefined types Integer, Char, WideChar, Boolean, and declared enumerated types.

Ordinal types are required in several different situations:

  • The index type of an array must be ordinal.
  • The low and high bounds of a subrange type must be constant expressions of ordinal type.
  • The element type of a set must be an ordinal type.
  • The selection expression of a case statement must be of ordinal type.
  • The first argument to the standard procedures Inc and Dec must be a variable of either ordinal or pointer type.

program Produce;
type
  TByteSet = set of 0..7;
var
  BitCount: array [TByteSet] of Integer;
begin
end.

The index type of an array must be an ordinal type – type TByteSet is a set, not an ordinal.

program Solve;
type
  TByteSet = set of 0..7;
var
  BitCount: array [Byte] of Integer;
begin
end.

Supply an ordinal type as the array index type.

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