Currently Boo creates a new local for the sole usage of one "for loop" even if a local with the same name have been declared before.
def Foo():
yield 1
yield 2
x = 0
for x in Foo(): #generated IL is actually "for x2 in.." or whatever.
pass
print x #prints 0
Boo should reuse a local when it has been declared earlier in the body (including in the optimized case of "for in range").
Testcase:
"""
2
9
2
5
"""
def Foo():
yield 1
yield 2
x = 0
for x in Foo():
pass
print x
j = 0
for j in range(10):
pass
print j
for i in range(10, 0, -2):
pass
print j
for j in (1, 1, 2, 3, 5):
pass
print j
Description
Currently Boo creates a new local for the sole usage of one "for loop" even if a local with the same name have been declared before.
def Foo():
yield 1
yield 2
x = 0
for x in Foo(): #generated IL is actually "for x2 in.." or whatever.
pass
print x #prints 0
Boo should reuse a local when it has been declared earlier in the body (including in the optimized case of "for in range").
Testcase:
"""
2
9
2
5
"""
def Foo():
yield 1
yield 2
x = 0
for x in Foo():
pass
print x
j = 0
for j in range(10):
pass
print j
for i in range(10, 0, -2):
pass
print j
for j in (1, 1, 2, 3, 5):
pass
print j
Add a range testcase with step=-2.