Skip to content

Spurious redundant-condition when using nonlocal #5563

Open

Description

@MorganBennetDev

Describe the Bug

In the sandbox link I posted, Pyrefly warns that if test is redundant and will always evaluate to False. However, at runtime the else branch is taken. This appears to be due to the nonlocal test statement in do_thing not being recognized as mutating test.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pVXLTsMwEPwV0xyChMDAEYkjh974gEhVmpjEIvVWfvD9zG5a7Ia2l-YUrT2z3vV49pJl8hWGffKWUthw0vujNJgYR3kuJd_TJo6wjr9N_DlyE3XtJIgcFvzDu3pZEFAcjT9Dk7lzLP9BN0xY7M9KaFbrr2ZVwApVv-boQtUl_gNLlxhyVQehzOFlJVzlopH_lVOpzzmgDpcAz4TkhgRnhpSeGlfBlI0aY9yHN62PcPKDNk731AV9gtCKH0n701rx-1M6RaL0ANpbJFvPiq2vCbbmirGDC1jXPez428jR0J2gImGYxW7EK77jNCkA35GnFK1YXdY7EwhGADyGMAO3CYNkaoegcHbpNzjHFg7jDcjBTrsdljhhknTGSTssbq7iSTbZzsbHLQZRke3qg_kF

(Only applicable for extension issues) IDE Information

No response

Activity

  1. added theissue type on Nov 7, 2026
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

    scoping-control-flowissues related to scoping and control flow

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions