[Frontend] Enforce an error was emitted for invalid conformance

Make sure we emitted an error if we encountered an invalid conformance
error. This is important since `ASTContext::hadError` accounts for
such delayed errors, so we need to make sure we don't ever exit with
a non-zero exit code without emitting any error.
This commit is contained in:
Hamish Knight
2025-11-28 22:13:43 +00:00
parent a69dbb3366
commit 7b8f112688
2 changed files with 16 additions and 2 deletions

View File

@@ -1120,6 +1120,13 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
// Emit extracted constant values for every file in the batch
emitConstValuesForAllPrimaryInputsIfNeeded(Instance);
// Make sure we emitted an error if we encountered an invalid conformance.
// This is important since `ASTContext::hadError` accounts for delayed
// conformance diags, so we need to ensure we don't exit with a non-zero exit
// code without emitting any error.
ASSERT(ctx.Diags.hadAnyError() || !ctx.hasDelayedConformanceErrors() &&
"Encountered invalid conformance without emitting error?");
}
static bool printSwiftVersion(const CompilerInvocation &Invocation) {