Sema: Add flag to force a crash if salvage() found a valid solution

This commit is contained in:
Slava Pestov
2026-02-09 11:11:07 -05:00
parent c8ba1fd652
commit 272f8fefeb
5 changed files with 60 additions and 14 deletions

View File

@@ -2028,6 +2028,22 @@ SolutionResult ConstraintSystem::salvage() {
if (*best != 0)
viable[0] = std::move(viable[*best]);
viable.erase(viable.begin() + 1, viable.end());
if (getASTContext().TypeCheckerOpts.CrashOnValidSalvage) {
auto &solution = viable[0];
if (solution.Fixes.empty() &&
diagnosticTransaction == nullptr &&
!getASTContext().LangOpts.DisableAvailabilityChecking &&
solution.getFixedScore().Data[SK_Unavailable] == 0 &&
solution.getFixedScore().Data[SK_Hole] == 0 &&
solution.getFixedScore().Data[SK_Fix] == 0) {
ABORT([&](auto &out) {
out << "Found valid solution in salvage()\n\n";
solution.dump(out, 0);
});
}
}
return SolutionResult::forSolved(std::move(viable[0]));
}