[red-knot] Avoid unresolved-reference in unreachable code#17169
Merged
Conversation
Contributor
|
09d3e62 to
27bee00
Compare
27bee00 to
77652a3
Compare
77652a3 to
a844c8c
Compare
dcreager
approved these changes
Apr 3, 2025
Member
dcreager
left a comment
There was a problem hiding this comment.
I love it when the commentary is so much longer than the fix!
Contributor
Author
|
|
dcreager
added a commit
that referenced
this pull request
Apr 3, 2025
* 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)
maxmynter
pushed a commit
to maxmynter/ruff
that referenced
this pull request
Apr 3, 2025
…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.
sharkdp
added a commit
that referenced
this pull request
Apr 8, 2025
## 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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