For in loop variable can be assigned to
Original Reporter info from Mantis: michael @mvancanneyt
-
Reporter name: Michael Van Canneyt
Original Reporter info from Mantis: michael @mvancanneyt
- Reporter name: Michael Van Canneyt
Description:
In a for..loop the compiler will report an error if you try to assign a value to the loop variable.
So writing
for I:=1 to 10 do
begin
Writeln(i);
I:=I+1;
end;
with the intention to write all odd numbers, will fail.
This logic or restriction has not been implemented for the for in loop.
It is perfectly possible to do
Var
A : Array[1..10] of Integer;
E : Integer;
begin
for E in A do
E:=1;
end.
Steps to reproduce:
compiling the following should produce an error on the line E:=1:
Var
A : Array[1..10] of Integer;
E : Integer;
begin
for E in A do
E:=1;
end.
Additional information:
Discussed on FPC core 14 Nov 2013
Mantis conversion info:
- Mantis ID: 25318
- OS: all
- OS Build: all
- Platform: all
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 26108 (#6e7cc222)