pylint-bot / test

0 stars 0 forks source link

Scope lookup problem when using closures #180

Open pylint-bot opened 8 years ago

pylint-bot commented 8 years ago

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?)


Given the following code, astroid doesn't understand the fact that the result will always be 24, instead it returns an union between the global and the value from the enclosing scope.

#!python

from astroid.test_utils import extract_node
n = extract_node('''
next = 42
def wrapper(next=next):     
     next = 24
     def test():
         return next
     return test
wrapper()() #@
''')
f = n.inferred()
print(f)
print(f[0].value)