Repository navigation
Commit fe98edc
authored
Fix new style union aliases with not ready items (#22172)
Fixes #21263
Fixes #11887
Old style aliases with new style unions are quite tricky, since this
requires some heuristics to figure out whether this is a type alias or a
regular variable. Things get even trickier when some items are not
ready, because our heuristics must be robust w.r.t. to this.
I spent few hours today playing with this, and I don't think there is a
fully-principled fix that doesn't involve rewriting a bunch of logic.
But I think I have something that is still fairly principled. Namely, in
this PR:
* Handle `becomes_typeinfo` status for imported placeholders
consistently.
* Put `should_wait_rhs()` back in sync with `can_be_type_alias()` w.r.t.
`OpExpr`.
* Add "backtracking" logic (maybe type alias -> actually a regular
variable) for one rare case that is tricky to handle otherwise.
Note, the root cause of the crash is that we normally never change a
type alias back to a regular variable. Normal flow for a symbol table
entry is always like this `None -> PlaceholderNode ->
PlaceholderNode(becomes_typeinfo=True) -> SymbolNode` (where some steps
may be skipped). A lot of logic depends on this, but in the relevant
scenarios it is tricky to follow this principle.1 parent 69dcb38 commit fe98edc
3 files changed
Lines changed: 88 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3136 | 3136 | | |
3137 | 3137 | | |
3138 | 3138 | | |
3139 | | - | |
| 3139 | + | |
3140 | 3140 | | |
3141 | 3141 | | |
3142 | 3142 | | |
| |||
3385 | 3385 | | |
3386 | 3386 | | |
3387 | 3387 | | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
3388 | 3392 | | |
3389 | 3393 | | |
3390 | 3394 | | |
| |||
3533 | 3537 | | |
3534 | 3538 | | |
3535 | 3539 | | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
3536 | 3545 | | |
3537 | 3546 | | |
3538 | 3547 | | |
| |||
3543 | 3552 | | |
3544 | 3553 | | |
3545 | 3554 | | |
3546 | | - | |
| 3555 | + | |
3547 | 3556 | | |
3548 | 3557 | | |
3549 | 3558 | | |
| |||
4251 | 4260 | | |
4252 | 4261 | | |
4253 | 4262 | | |
| 4263 | + | |
| 4264 | + | |
| 4265 | + | |
4254 | 4266 | | |
4255 | 4267 | | |
4256 | 4268 | | |
| |||
6862 | 6874 | | |
6863 | 6875 | | |
6864 | 6876 | | |
| 6877 | + | |
| 6878 | + | |
| 6879 | + | |
| 6880 | + | |
6865 | 6881 | | |
6866 | 6882 | | |
6867 | 6883 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
3248 | 3248 | | |
3249 | 3249 | | |
3250 | 3250 | | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
0 commit comments