Skip to content

Reusing variable previously defined with walrus operator triggers used-before-def error #14626

Description

@goldenfire6

To Reproduce

x = 3
z = (y := str(x)).index(y.lower())

Expected Behavior

Should be no errors -- this code does not error using mypy v0.991 or prior, so this seems to be a new issue with v1.0.0.

Actual Behavior

error: Name "y" is used before definition [used-before-def]

Your Environment

  • Mypy version used: 1.0.0
  • Mypy command-line flags: none
  • Python version used: 3.9

Activity

  1. ilinum commented on Feb 8, 2023

    @ilinum
    Collaborator

    Thanks for reporting! We will include the fix in the 1.0.1 release.

  2. added a commit that references this issue on Feb 8, 2023
    6b56dc0
  3. added 3 commits that reference this issue on Feb 8, 2023
    e683aa4
    4e2a113
    c090ca2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions