-
Notifications
You must be signed in to change notification settings - Fork 226
Description
Summary
For example, in this snippet we should not emit a possibly-unresolved-reference error on the use of x inside the if block, because we can only reach the inside of the if block in a case where the assignment expression has definitely executed:
def _(flag: bool, number: int):
if flag and (x := number):
reveal_type(x)(Note that we disable possibly-unresolved-reference by default, so to reproduce this on the command line you'll have to use --error possibly-unresolved-reference.)
This was previously fixed in astral-sh/ruff#18010, but the fix caused a large performance regression in some cases (see #431 for details) and was reverted in astral-sh/ruff#18150. So one useful way to approach this issue is to reapply the previous fix and explore the cause of the performance regression (and add a benchmark that would catch that regression in future.)
Version
No response