Commit 0a8d425
authored
Fix spurious unreachable and disallow-any errors from deferred passes (#13575)
This diff:
- Fixes #8129
- Fixes #13043
- Fixes #13167
For more concise repros of these various issues, see the modified test files. But in short, there were two broad categories of errors:
1. Within the deferred pass, we tend to infer 'Any' for the types of different variables instead of the actual type. This interacts badly with our unreachable and disallow-any checks and causes spurious errors.
Arguably, the better way of handling this error is to only collect errors during the final pass. I briefly experimented with this
approach, but was unable to find a clean, efficient, and non-disruptive way of implementing this. So, I settled for sprinkling in a few more `not self.current_node_deferred` checks.
2. The `self.msg.disallowed_any_type(...)` call is normally guarded behind a `not self.chk.current_node_deferred` check. However, we were bypassing this check for `except` block assignments because we were deliberately setting that flag to False to work around some bug. For more context, see #2290.
It appears we no longer need this patch anymore. I'm not entirely sure why, but I'm guessing we tightened and fixed the underlying problem with deferred passes some time during the past half-decade.1 parent cf7495f commit 0a8d425
File tree
4 files changed
+49
-8
lines changed- mypy
- test-data/unit
4 files changed
+49
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1207 | 1209 | | |
1208 | 1210 | | |
1209 | 1211 | | |
| |||
2431 | 2433 | | |
2432 | 2434 | | |
2433 | 2435 | | |
| 2436 | + | |
2434 | 2437 | | |
2435 | 2438 | | |
2436 | 2439 | | |
| |||
4179 | 4182 | | |
4180 | 4183 | | |
4181 | 4184 | | |
4182 | | - | |
4183 | | - | |
4184 | | - | |
4185 | | - | |
4186 | | - | |
4187 | | - | |
4188 | 4185 | | |
4189 | | - | |
4190 | 4186 | | |
4191 | 4187 | | |
4192 | 4188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
369 | 385 | | |
370 | 386 | | |
371 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
948 | 960 | | |
949 | 961 | | |
950 | 962 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1397 | 1397 | | |
1398 | 1398 | | |
1399 | 1399 | | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
0 commit comments