You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ty] Avoid duplicate bindings in multi-target assignments - #27938
Previously, chained assignments could panic when their shared right-hand side contained both an assignment expression and a lambda:
first=second= (named:=lambda: 0)
Each target independently imported the same nested binding, violating the uniqueness invariant for inferred bindings.
We now record whether an assignment's value bindings belong to its definition or its enclosing statement during semantic indexing. Statements claim shared bindings once while individual targets retain contextual expression inference. The same ownership rule handles unpacking, subscript targets, and assignment expressions in lambda defaults:
Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 97.69%. The percentage of expected errors that received a diagnostic held steady at 93.71%. The number of fully passing files held steady at 110/136.
The reason will be displayed to describe this comment to others. Learn more.
Could we have this case use different annotations on the two targets? With identical annotations, this test would still pass if we accidentally reused the first target's inferred callable type for both.
The reason will be displayed to describe this comment to others. Learn more.
I don't really think it's worth adding Rust unit tests for this. I can't see what observable failure would be caused by failing to store this metadata correctly, that wouldn't cause the mdtests to fail.
I'm not usually one to turn down test coverage, but overall my feeling is that this PR is over-tested for the very niche edge case it handles.
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
bugAn issue describing something that isn't working, or a PR that fixes a bugtyThe ty type checker
2 participants
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
Previously, chained assignments could panic when their shared right-hand side contained both an assignment expression and a lambda:
Each target independently imported the same nested binding, violating the uniqueness invariant for inferred bindings.
We now record whether an assignment's value bindings belong to its definition or its enclosing statement during semantic indexing. Statements claim shared bindings once while individual targets retain contextual expression inference. The same ownership rule handles unpacking, subscript targets, and assignment expressions in lambda defaults: