[fpc-pascal] Illegal counter variable?

Jonas Maebe jonas at freepascal.org
Mon Sep 9 16:54:01 CEST 2019


On 2019-09-09 11:30, James Richters wrote:
> Can someone please tell me why this happens?
> 
> Var
>    I : Longint = 0;
> Begin
> For I := 1 to 6 Do
>    Writeln(I);
> End.
> 
> This gives me :
> initialize.pas(4,5) Error: Illegal counter variable
> initialize.pas(6,4) Fatal: There were 1 errors compiling module, 
> stopping
> initialize.pas(0) Fatal: Compilation aborted

"var i : longint = 0;" is internally handled using the same code path as 
"const i : longint = 0", and typed constants cannot be used as counter 
variables. This is indeed probably a bug.


Jonas


More information about the fpc-pascal mailing list