Currently, this code: var i: Integer; a: array [1..10] of Integer; ... for i in a do i += 1;
Is compiled and silently does nothing. Assignment to the for..in loop variable is currently not supported by Delphi either: http://docwiki.embarcadero.com/RADStudio/en/Declarations_and_Statements#Iteration_Over_Containers_Using_For_statements however, there are some good use cases for this: http://stackoverflow.com/questions/2246087/delphi-variable-used-in-the-for-in-cannot-be-assigned So, I have a bug report/feature request: 1) In the current implementation, FPC should at least warn on attempt to change for..in loop variable (I assumed that since it compiles, it works, and it cost me much time to debug this) 2) Ideally, FPC for loop variable should have the same semantics as var parameter, so changing it should change the underlying data. -- Alexander S. Klenin _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
