Skip to content

Commit ce35731

Browse files
committed
[Constraint solver] Reinstate the fallback diagnostic, just in case.
1 parent e0702d9 commit ce35731

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/Sema/CSSolver.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,24 @@ static bool debugConstraintSolverForTarget(
11071107
return startBound != endBound;
11081108
}
11091109

1110+
/// If we aren't certain that we've emitted a diagnostic, emit a fallback
1111+
/// diagnostic.
1112+
static void maybeProduceFallbackDiagnostic(
1113+
ConstraintSystem &cs, SolutionApplicationTarget target) {
1114+
if (cs.Options.contains(ConstraintSystemFlags::SubExpressionDiagnostics) ||
1115+
cs.Options.contains(ConstraintSystemFlags::SuppressDiagnostics))
1116+
return;
1117+
1118+
// Before producing fatal error here, let's check if there are any "error"
1119+
// diagnostics already emitted or waiting to be emitted. Because they are
1120+
// a better indication of the problem.
1121+
ASTContext &ctx = cs.getASTContext();
1122+
if (ctx.Diags.hadAnyError() || ctx.hasDelayedConformanceErrors())
1123+
return;
1124+
1125+
ctx.Diags.diagnose(target.getLoc(), diag::failed_to_produce_diagnostic);
1126+
}
1127+
11101128
Optional<std::vector<Solution>> ConstraintSystem::solve(
11111129
SolutionApplicationTarget &target,
11121130
ExprTypeCheckListener *listener,
@@ -1152,6 +1170,7 @@ Optional<std::vector<Solution>> ConstraintSystem::solve(
11521170
}
11531171

11541172
case SolutionResult::Error:
1173+
maybeProduceFallbackDiagnostic(*this, target);
11551174
return None;
11561175

11571176
case SolutionResult::TooComplex:

0 commit comments

Comments
 (0)