Delphi E2013 Type of expression must be INTEGER

Only when the constant expression that specifies the amount of characters in a string type is not of type integer does this error message appear.

program Produce;
type
  color = (red,green,blue);
var
  S3 : string[Succ(High(color))];
begin
end.

The example attempts to describe the number of elements in a string as a function of the maximum element of type colour; however, the element count is of type colour, which is prohibited.

program Solve;
type
  color = (red,green,blue);
var
  S3 : string[ord(High(color))+1];
begin
end.
%d bloggers like this: