Skip to content

redefinition in closure functions  #124002

@MirS0bhan

Description

@MirS0bhan

Bug report

Bug description:

i think it could be a bug or maybe we just need a PEP but I issue it here
in closure functions we cant redefine a var that has defined before in the parent function
as the normal action I think it should resolve it because is happens normally but when we use it in a
redefinition it doesn't work.

def foo(x: int):
    x: int = x * x
    def john():
        x: int = x + x
        return x
    return john

error: Unresolved reference 'x'

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions