[ty] Ignore rejected assignments for synthesized bindings (#25340)
## Summary
Prior to this change, we were retaining "known key" bindings from the
right-hand side of an assignment even when the enclosing assignment was
rejected. For example:
```python
def _(x: dict[str, int]):
x = {"a": "bad"} # error: invalid-assignment
reveal_type(x["a"]) # Should be int, but main shows Literal["bad"]
```
So we're respecting the new type information from `x = {"a": "bad"}`...
But an invalid assignment shouldn't contribute new type information!
In other words, we want to ignore the known-key bindings that we get
from the dict assignment when the overall assignment is invalid.
Doing so is pretty ugly because the index is built solely from syntax
(e.g., we create definitions from `x = {"a": "bad"}`), but we're trying
to _reject_ those definitions later during inference, using information
we don't have at the time of definition creation. I tried a variety of
approaches but this ended up being the cheapest and least invasive thing
I could find. C
Charlie Marsh committed
6c88390f7d49068c6fc2a0102145c3bdd5318e35
Parent: d33907f
Committed by GitHub <noreply@github.com>
on 5/30/2026, 9:04:59 AM