Skip to content

Commit 565ed69

Browse files
authored
Merge pull request #42605 from xedin/abort-solver-on-too-complex
[CSStep] Abort any binding step when constraint system is 'too complex'
2 parents 3c8ec81 + e2b4759 commit 565ed69

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5494,6 +5494,9 @@ class ConstraintSystem {
54945494
}
54955495

54965496
bool getExpressionTooComplex(SmallVectorImpl<Solution> const &solutions) {
5497+
if (isExpressionAlreadyTooComplex)
5498+
return true;
5499+
54975500
size_t solutionMemory = 0;
54985501
for (auto const& s : solutions) {
54995502
solutionMemory += s.getTotalMemory();

lib/Sema/CSStep.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ template <typename P> class BindingStep : public SolverStep {
504504

505505
public:
506506
StepResult take(bool prevFailed) override {
507+
// Before attempting the next choice, let's check whether the constraint
508+
// system is too complex already.
509+
if (CS.getExpressionTooComplex(Solutions))
510+
return done(/*isSuccess=*/false);
511+
507512
while (auto choice = Producer()) {
508513
if (shouldSkip(*choice))
509514
continue;

0 commit comments

Comments
 (0)