Skip to content

Commit aab3de7

Browse files
committed
[Constraint solver] Exit immediately from solve() if we already have a failed constraint.
As solveRec() already does, exit immediately if we have a failed constraint from constraint generation. Not doing so means that we can create a SolverScope in constraint propagation, and on destruction of that SolverScope we clear out the failedConstraint field, obscuring the fact that we had a failure.
1 parent 0328139 commit aab3de7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
462462
PreviousScore = cs.CurrentScore;
463463

464464
cs.solverState->registerScope(this);
465+
assert(!cs.failedConstraint && "Unexpected failed constraint!");
466+
465467
++cs.solverState->NumStatesExplored;
466468
}
467469

@@ -1986,7 +1988,7 @@ bool ConstraintSystem::solve(SmallVectorImpl<Solution> &solutions,
19861988
// Simplify any constraints left active after constraint generation
19871989
// and optimization. Return if the resulting system has no
19881990
// solutions.
1989-
if (simplify())
1991+
if (failedConstraint || simplify())
19901992
return true;
19911993

19921994
// If the experimental constraint propagation pass is enabled, run it.

0 commit comments

Comments
 (0)