Skip to content

member field + lambda results unexpected UnboundLocalError #3934

@youknowone

Description

@youknowone

Code:

class X:
    v = 10
    f = lambda x=v: x

Expected:
silence

Actual:

Traceback (most recent call last):
  File "test_lambda_scope.py", line 3, in <module>
    f = lambda x=v: x
  File "test_lambda_scope.py", line 3, in X
    f = lambda x=v: x
UnboundLocalError: local variable 'v' referenced before assignment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-compilerArea: compilerC-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions