Skip to content

Commit e97fa24

Browse files
authored
[DiagnosticVerifier] Do not capture 'fatal error encountered' errors (#84640)
When the diagnostic verifier encounters a fatal error, it reports: <unknown>:0: error: fatal error encountered while in -verify mode If we capture this, and fail to match this against an expected-error, the diagnostic verifier complains: <unknown>:0: error: unexpected error produced: fatal error encountered while in -verify mode <unknown>:0: error: diagnostic produced elsewhere: fatal error encountered while in -verify mode The current workaround is to use -verify-ignore-unknown, but that in turn may mask actual errors coming from unknown source locations. Ignoring these errors about errors removes the need for that workaround.
1 parent 9d1b57f commit e97fa24

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "swift/Frontend/DiagnosticVerifier.h"
18+
#include "swift/AST/DiagnosticsFrontend.h"
1819
#include "swift/Basic/Assertions.h"
1920
#include "swift/Basic/ColorUtils.h"
2021
#include "swift/Basic/SourceManager.h"
@@ -1454,6 +1455,10 @@ processExpansions(SourceManager &SM, llvm::DenseMap<SourceLoc, unsigned> &Expans
14541455
/// file.
14551456
void DiagnosticVerifier::handleDiagnostic(SourceManager &SM,
14561457
const DiagnosticInfo &Info) {
1458+
// Ignore "fatal error encountered while in -verify mode" errors,
1459+
// because there's no reason to verify them.
1460+
if (Info.ID == diag::verify_encountered_fatal.ID)
1461+
return;
14571462
SmallVector<CapturedFixItInfo, 2> fixIts;
14581463
for (const auto &fixIt : Info.FixIts) {
14591464
fixIts.emplace_back(SM, fixIt);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
import Expected // expected-error {{no such module 'Expected'}}

0 commit comments

Comments
 (0)