py: Fix optimised for-loop compiler so it follows proper semantics.

You can now assign to the range end variable and the for-loop still
works correctly.  This fully addresses issue #565.

Also fixed a bug with the stack not being fully popped when breaking out
of an optimised for-loop (and it's actually impossible to write a test
for this case!).
This commit is contained in:
Damien George
2014-12-12 17:19:56 +00:00
parent 7764f163fa
commit e181c0dc07
2 changed files with 43 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ for i in range(2):
# test assigning to range parameter within the loop
# (since we optimise for loops, this needs checking, currently it fails)
#n = 2
#for i in range(n):
# print(i)
# n = 0
n = 2
for i in range(n):
print(i)
n = 0