PythonExtra/tests/basics/unboundlocal.py
Damien George 6ce4277551 py: Make all LOAD_FAST ops check for unbound local.
This is necessary to catch all cases where locals are referenced before
assignment.  We still keep the _0, _1, _2 versions of LOAD_FAST to help
reduced the byte code size in RAM.

Addresses issue #457.
2014-04-12 18:20:40 +01:00

20 lines
242 B
Python

# locals referenced before assignment
def f1():
print(x)
x = 1
def f2():
for i in range(0):
print(i)
print(i)
def check(f):
try:
f()
except NameError:
print("NameError")
check(f1)
check(f2)