-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[red-knot] Avoid unresolved-reference in unreachable code #17169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] Avoid unresolved-reference in unreachable code #17169
Conversation
|
09d3e62 to
27bee00
Compare
27bee00 to
77652a3
Compare
77652a3 to
a844c8c
Compare
dcreager
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it when the commentary is so much longer than the fix!
|
|
* origin/main: [red-knot] Add `Type::TypeVar` variant (#17102) [red-knot] update to latest Salsa with fixpoint caching fix (#17179) Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) [red-knot] Avoid unresolved-reference in unreachable code (#17169) Fix relative import resolution in `site-packages` packages when the `site-packages` search path is a subdirectory of the first-party search path (#17178) [DO NOT LAND] bump Salsa version (#17176) [syntax-errors] Detect duplicate keys in `match` mapping patterns (#17129)
…17169) ## Summary This PR changes the inferred type for symbols in unreachable sections of code to `Never` (instead of reporting them as unbound), in order to silence false positive diagnostics. See the lengthy comment in the code for further details. ## Test Plan - Updated Markdown tests. - Manually verified a couple of ecosystem diagnostic changes.
## Summary This implements a new approach to silencing `unresolved-reference` diagnostics by keeping track of the reachability of each use of a symbol. The changes merged in #17169 are still needed for the "Use of variable in nested function" test case, but that could also be solved in another way eventually (see https://github.com/astral-sh/ruff/issues/15777). We can use the same technique to silence `unresolved-import` and `unresolved-attribute` false-positives, but I think this could be merged in isolation. ## Test Plan New Markdown tests, ecosystem tests
Summary
This PR changes the inferred type for symbols in unreachable sections of code to
Never(instead of reporting them as unbound), in order to silence false positive diagnostics. See the lengthy comment in the code for further details.Test Plan