Skip to content

Commit 2b875c5

Browse files
committed
[CSStep] Conjunction: Reset current/best score only on failure
Successful conjunction should preseve a score set by a follow-up solve with outer context. Failure should reset the score back to original one pre-conjunction.
1 parent 338cc32 commit 2b875c5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/CSStep.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,12 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
907907
// Restore conjunction constraint.
908908
restore(AfterConjunction, Conjunction);
909909

910-
// Restore best score.
911-
CS.solverState->BestScore = BestScore;
912-
CS.CurrentScore = CurrentScore;
910+
// Restore best score only if conjunction fails because
911+
// successful outcome should keep a score set by `restoreOuterState`.
912+
if (HadFailure) {
913+
CS.solverState->BestScore = BestScore;
914+
CS.CurrentScore = CurrentScore;
915+
}
913916
}
914917

915918
StepResult resume(bool prevFailed) override;

0 commit comments

Comments
 (0)