Skip to content

Scope lookup problem when using closures #180

@pylint-bot

Description

@pylint-bot

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions