Commit 5679a89
committed
Fix 1.20 regression: use explicit walrus check instead of binder version guard
The binder version guard introduced in PR #20622 was too broad: it
disabled union fallback for any expression that modifies the binder,
including generator expressions with ternary operators. This caused
type narrowing via reassignment to fail for non-walrus expressions.
Replace the binder_version == self.binder.version check with an
explicit check for AssignmentExpr (walrus :=) in the expression tree,
which is the actual problematic case. This restores type narrowing
for generator expressions and other non-walrus constructs while
preserving the walrus safety guard.1 parent 93bc02b commit 5679a89
1 file changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
382 | 393 | | |
383 | 394 | | |
384 | 395 | | |
| |||
4757 | 4768 | | |
4758 | 4769 | | |
4759 | 4770 | | |
4760 | | - | |
| 4771 | + | |
4761 | 4772 | | |
4762 | 4773 | | |
4763 | 4774 | | |
| |||
4787 | 4798 | | |
4788 | 4799 | | |
4789 | 4800 | | |
4790 | | - | |
| 4801 | + | |
4791 | 4802 | | |
4792 | 4803 | | |
4793 | 4804 | | |
| |||
5091 | 5102 | | |
5092 | 5103 | | |
5093 | 5104 | | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
| 5109 | + | |
| 5110 | + | |
| 5111 | + | |
5094 | 5112 | | |
5095 | 5113 | | |
5096 | 5114 | | |
| |||
0 commit comments