[ty] Fix loop-header reachability cycles in conditional unpacking by charliermarsh · Pull Request #24006 · astral-sh/ruff (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this diff:
- deleted_reachability: self.deleted_reachability,
- deleted_reachability: self.deleted_reachability.or(previous.deleted_reachability),
The following example emits a warning:
x = 1
warning[possibly-unresolved-reference]:
while x < 10: # warning[possibly-unresolved-reference]: if x == 4: del x
So I think leaving it is correct (though it is possible it may prevent cycle convergence in some cases, but if we don't have a reproduction we can leave it for now). As @carljm points out, I think this means that your change also has the same problem of over-estimating the definedness of bindings within the loop, but I think it's fine to land for now to fix the cycle panics.