Skip to content

False negative for NameError from calling inner function before variable is assigned #8495

Open
@jacobtylerwalls

Description

@jacobtylerwalls

Bug description

def outer():
    def inner():
        print(i)
    
    inner()
    for i in range(5):
        inner()

outer()

Configuration

No response

Command used

pylint a.py

Pylint output

no msg

Expected behavior

A new message possibly-used-before-assignment on line 3. Notice the second call to inner() executes fine.

Pylint version

pylint 3.0.0a6
astroid 2.16.0dev0
Python 3.11.2

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: used-before-assignmentIssues related to 'used-before-assignment' checkControl flowRequires control flow understandingFalse Negative 🦋No message is emitted but something is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions