Delphi – E2011 Low bound exceeds high bound

When the low bound of a subrange type is more than the high bound, or the low bound of a case label range is bigger than the high bound, this error message is displayed.

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.

Instead of considering the ranges as empty in the preceding example, the compiler throws an error. The reversing of the bounds was most likely unintentional.


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

Make sure the boundaries are stated in the correct order.