Skip to content

Commit 82d8849

Browse files
committed
[Diagnostics] Eliminate silent exits on precondition violations
The diagnostic bridging code from C++ diagnostics to swift-syntax was silently returning on certain preconditions. These should never happen, and if they did would silently drop diagnostics on the floor, leading to much consternation. Turn them into proper fatalErrors.
1 parent eb5f5dd commit 82d8849

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/ASTGen/Sources/ASTGen/DiagnosticsBridge.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public func addQueuedDiagnostic(
267267
)
268268

269269
guard let rawPosition = cLoc.getOpaquePointerValue() else {
270-
return
270+
fatalError("Cannot emit diagnostic with no source location here")
271271
}
272272

273273
// Find the source file that contains this location.
@@ -279,8 +279,7 @@ public func addQueuedDiagnostic(
279279
return rawPosition >= baseAddress && rawPosition <= baseAddress + sf.buffer.count
280280
}
281281
guard let sourceFile = sourceFile else {
282-
// FIXME: Hard to report an error here...
283-
return
282+
fatalError("Missing source file for diagnostic")
284283
}
285284

286285
let sourceFileBaseAddress = UnsafeRawPointer(sourceFile.buffer.baseAddress!)
@@ -302,8 +301,7 @@ public func addQueuedDiagnostic(
302301
node = sourceFile.syntax
303302
}
304303
} else {
305-
// position out of range.
306-
return
304+
fatalError("Diagnostic position is outside of its source file")
307305
}
308306

309307
// Map the highlights.

0 commit comments

Comments
 (0)