The for statement discards the variable changes
This is the intended behavior. If you want the variable to be global, you should switch the --for-local or --posixly-correct option.
Thanks!
This is the intended behavior. If you want the variable to be global, you should switch the --for-local or --posixly-correct option.
Even if this is intended, then in my opinion it's an unexpected behavior.
I presume that the goal is to have the "for" variable loop local to the "for" loop.
However, as it stands - and as the test case demonstrates, it remains local to the function even after the for loop.
So the current design is: - The "for" variable becomes local to the function inside and after the "for" loop.
And a better design would be, in my opinion: - The "for" variable becomes local to the "for" loop only inside the "for" loop.
The "for" variable becomes local to the "for" loop only inside the "for" loop.
I don't find the behavior effectively more useful than the current. That would only complicate the implementation.
Tested on Yash 2.50 on Debian bullseye and Yash 2.51 on macOS (Homebrew).