-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Prune constraints that could turn into cycles #1058
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
The issue uncovered a much deeper problem with constraint solving, which we solve by deliberatley |
Interesting approach, do you think that you could create a |
@smarter Logically, |
@smarter Also note that the cycle check does not catch cycles of length > 1. |
prune(bound.underlying) | ||
case bound: PolyParam if constraint contains bound => | ||
if (!addParamBound(bound)) NoType | ||
else if (fromBelow) defn.NothingType |
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.
What about narrowing a bit less by using something like prune(constraint.nonParamBounds(bound).lo)
instead of defn.NothingType
?
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.
That would not add anything. By recording the isLess we get the bounds anyway.
Should we add a debug log message when we narrow bounds? Otherwise it might be easy to overlook when trying to understand why some code does not compile. |
I don't think we need a log message. The cases where this will fail will be really rare, and should be easily caught already by turning on the constr printer. Without constr, I think t will be impossible to diagnose. |
* are tested for direct or indirect dependencies, each time a | ||
* constraint is added in TypeComparer. | ||
/** Make sure none of the bounds in an OrderingConstraint contains | ||
* another constrained parameter at its toplevel (i.e. as an operand |
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.
You say "another constrained parameter" but the check does b eq param
, so shouldn't you say something like "Make sure none of the bounds of a parameter in an OrderingConstraint contains this parameter at its toplevel" ?
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.
yes, indeed. Can you make that change please? Thanks!
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.
Done, also fixed the documentation of addConstraint
.
Prune constraints that could turn into cycles
Fixes #864. Review by @smarter.