For loops final value out of range

Official Description

6.8.3.9 For a for-statement, it is an error if the value of the final-value is not assignment-compatible with the type possessed by the control-variable, if the statement of the for-statement is executed.

Simplified Description

In other words, it is an error if the following two conditions are met:

For example given:

   type num = 1..100;
   var n : num;

then the following are errors:

   for n := 1 to 101 do writeln(n);
   for n := 100 downto 0 do writeln(n);

But the following are not errors since the for loops are never started (and therefore no assignments are made to the control variable n).

   for n := 1 downto 101 do writeln(n);
   for n := 100 to 0 do writeln(n);

Error Handling

This error is reported if range checking is enabled.