-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Only normalize constraint bounds for display #21516
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
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
| ) { | ||
| // These might seem redundant with the intersection check below, since `a → b` means that | ||
| // `a ∧ b = a`. But we are not normalizing constraint bounds, and these clauses help us | ||
| // identity constraints that are identical besides e.g. ordering of union/intersection |
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.
| // identity constraints that are identical besides e.g. ordering of union/intersection | |
| // identify constraints that are identical besides e.g. ordering of union/intersection |
| if left_constraint.implies(db, right_constraint) { | ||
| self.add_single_implication(left_constraint, right_constraint); | ||
| } | ||
| if right_constraint.implies(db, left_constraint) { | ||
| self.add_single_implication(right_constraint, left_constraint); | ||
| } |
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.
The explanation above seems to imply that we could (should?) return early here? Because if a → b always implies a ∧ b = a, then the code below would otherwise add two additional a → b implications and one a → a implication, both of which seem unnecessary?
We were previously normalizing the upper and lower bounds of each constraint when constructing constraint sets. Like in #21463, this was for conflated reasons: It made constraint set displays nicer, since we wouldn't render multiple constraints with obviously equivalent bounds. (Think
T ≤ A & BandT ≤ B & A) But it was also useful for correctness, since prior to #21463 we were (trying to) add the full transitive closure to a constraint set's BDD, and normalization gave a useful reduction in the number of nodes in a typical BDD.Now that we don't store the transitive closure explicitly, that second reason is no longer relevant. Our sequent map can store that full transitive closure much more efficiently than the expanded BDD would have. This helps fix some false positives on #20933, where we're seeing some (incorrect, need to be fixed, but ideally not blocking this effort) assignability failures between a type and its normalization.
Normalization is still useful for display purposes, and so we do normalize the upper/lower bounds before building up our display representation of a constraint set BDD.