py: Fix bug in optimised for .. range.

Don't store final, failing value to the loop variable.  This fix also
makes for .. range a bit more efficient, as it uses less store/load
pairs for the loop variable.
This commit is contained in:
Damien George
2014-03-31 18:02:22 +01:00
parent 8cd72bdf92
commit 3ff2d03891
3 changed files with 183 additions and 7 deletions

8
tests/basics/for2.py Normal file
View File

@@ -0,0 +1,8 @@
i = 'init'
for i in range(0):
pass
print(i) # should not have been modified
for i in range(10):
pass
print(i) # should be last successful value of loop