Delphi Error – E2011 Low bound exceeds high bound

Delphi Compiler Error

E2011 Low bound exceeds high bound

Reason for the Error & Solution

This error message is given when either the low bound of a subrange type is greater than the high bound, or the low bound of a case label range is greater than the high bound.

program Produce;
type
  SubrangeType = 1..0;              (*Gets: Low bound exceeds high bound *)
begin
  case True of
  True..False:                      (*Gets: Low bound exceeds high bound *)
    Writeln('Expected result');
  else
    Writeln('Unexpected result');
  end;
end.

In the example above, the compiler gives an error rather than treating the ranges as empty. Most likely, the reversal of the bounds was not intentional.

program Solve;
type
  SubrangeType = 0..1;
begin
  case True of
  False..True:
    Writeln('Expected result');
  else
    Writeln('Unexpected result');
  end;
end.

Make sure you have specified the bounds in the correct order.

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