-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] avoid fixpoint unioning of types containing current-cycle Divergent #21910
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
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
a697b63 to
9d17c17
Compare
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-assignment |
0 | 3 | 0 |
unresolved-attribute |
3 | 0 | 0 |
invalid-argument-type |
0 | 0 | 2 |
invalid-return-type |
0 | 0 | 2 |
unsupported-operator |
0 | 0 | 2 |
possibly-missing-attribute |
0 | 0 | 1 |
unused-ignore-comment |
1 | 0 | 0 |
| Total | 4 | 3 | 7 |
CodSpeed Performance ReportMerging #21910 will not alter performanceComparing Summary
Footnotes
|
|
With #21906, this no longer has any impact on our mdtests. Pushing a rebase to see if it has any ecosystem impact worth pursuing. |
|
Ok, this doesn't seem to hurt performance and there are cases in the ecosystem where it helps, so I think it's worth going ahead with. I'll add at least one example from the ecosystem as an mdtest and then put it up for review. |
| false, | ||
| ) | ||
| }; | ||
| if has_divergent_type_in_cycle(previous) && !has_divergent_type_in_cycle(self) { |
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.
If I remove the !has_divergent_type_in_cycle(self) requirement, we do get an oscillation in mdtest/regression/1377_iteration_count_mismatch.md. So it is possible to oscillate between types containing a Divergent from the current cycle. But it should not be possible to reintroduce a Divergent from the current cycle once it has been eliminated.
|
@mtshiba please take a look and let me know what you think. |
|
Looks good! |
Partially addresses astral-sh/ty#1732
Summary
Don't union the previous type in fixpoint iteration if the previous type contains a
Divergentfrom the current cycle and the latest type does not. The theory here, as outlined by @mtshiba at astral-sh/ty#1732 (comment), is that oscillation can't occur by removing and then reintroducing aDivergenttype repeatedly, sinceDivergenttypes are only introduced at the start of fixpoint iteration.Test Plan
Removes a
Divergenttype from the added mdtest, doesn't otherwise regress any tests.