-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[TypeChecker] Add retired constraints to the front of the list in SolverScope #6160
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
|
/cc @rudkx @DougGregor |
|
I don't understand how it is that this resolves a crash? |
|
@DougGregor The reason why it helps is because crash happens in |
|
Yeah the basic problem is that in ~SolverScope we restore the retiredConstraints to where they were prior to this scope, but that code assumes new retired constraints are pushed on the front of the list. It would be good to clean this up to refactor into clearly documented functions that capture the current state, restore the previous current state, and add newly retired constraints so that all the logic is kept together in one place. Otherwise this is just too easy to get wrong. @xedin Would you mind taking a crack at that? It doesn't have to be anything fancy - just something that makes it less likely to put constraints at the wrong end of the list in the future. |
|
@rudkx Absolutely! |
…verScope Since retired constraints are re-added back to the circulation in LIFO order, make sure that all of the constraints are added to the front of SolverScope::retiredConstraints list.
…generated constraints Instead of relying on the SolverScope to rollback all of the changes done to constraints in the system at the end of its life time, move all of the logic handling that into SolverState where retired/generated constraints live.
|
@rudkx Done! I've abstracted coupling between state and scope into register/rollback sequence, so state is now responsible for actual rollback logic, and added getter/setter methods to retired/generated constraints. |
|
@swift-ci Please smoke test |
rudkx
left a comment
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.
Awesome, LGTM!
|
I understand now, thank you for the fix (and the education)! |
Since retired constraints are re-added back to the circulation in LIFO
order, make sure that all of the constraints are added to the front of
SolverScope::retiredConstraints list.