[Type checker] Don't re-insert node types when merging solutions.

Merging partial solutions can end up assigning the same type to a
particular typed node (expression, parameter, etc.), which can lead to
unbalanced set/clear when exploring the solution space (and later on,
crashes). Don't re-insert such information.

This is the same approach taken for type variable bindings, but it's
all pretty unfortunate: partial solutions should only record
information relative to their part of the constraint system, which
would save time and memory during solving. Howver, that's too big a
change for right now.

Fixes rdar://problem/50853028.
This commit is contained in:
Doug Gregor
2019-05-16 21:37:34 -07:00
committed by John McCall
parent a183f762cd
commit 2594de613b
3 changed files with 30 additions and 20 deletions

View File

@@ -251,7 +251,8 @@ void ConstraintSystem::applySolution(const Solution &solution) {
// Add the node types back.
for (auto &nodeType : solution.addedNodeTypes) {
setType(nodeType.first, nodeType.second);
if (!hasType(nodeType.first))
setType(nodeType.first, nodeType.second);
}
// Register the conformances checked along the way to arrive to solution.