Expand the FOR documentation to cover some essential aspects
Original Reporter info from Mantis: pgimeno
-
Reporter name: Pedro Gimeno
Original Reporter info from Mantis: pgimeno
- Reporter name: Pedro Gimeno
Description:
I went to the documentation to check if FOR loops evaluate the second argument every iteration or not, but this aspect is not mentioned. The closest thing that it says is that "Free Pascal always calculates the upper bound before initializing the counter variable with the initial value", but that alone doesn't leave it clear that this upper bound is cached and not re-evaluated during iteration (which I've checked to be the case).
Furthermore, jumping from outside the loop to inside the loop via a GOTO statement is not explicitly forbidden. Doing this skips the caching phase of the upper bound, with unpredictable results, therefore it should not be allowed. Adding a check in the compiler may be difficult, but documenting that it's plainly not supported and the result is undefined is simpler.
Mantis conversion info:
- Mantis ID: 37911
- Fixed in version: 3.3.1
- Fixed in revision: 1766 (#1001a786)
- Target version: 3.2.2