Skip to content

Commit b18b29e

Browse files
authored
Merge pull request #37865 from xedin/rdar-78920375
[MiscDiagnostics] NFC: Add an assert that arguments a valid to `.nan`…
2 parents d3aeda0 + 299da73 commit b18b29e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4541,6 +4541,15 @@ static void diagnoseComparisonWithNaN(const Expr *E, const DeclContext *DC) {
45414541
auto *firstArg = BE->getLHS();
45424542
auto *secondArg = BE->getRHS();
45434543

4544+
// Make sure that both arguments are valid before doing anything else,
4545+
// this helps us to debug reports of crashes in `conformsToKnownProtocol`
4546+
// referencing arguments (rdar://78920375).
4547+
//
4548+
// Since this diagnostic should only be run on type-checked AST,
4549+
// it's unclear what caused one of the arguments to have null type.
4550+
assert(firstArg->getType() && "Expected valid type for first argument");
4551+
assert(secondArg->getType() && "Expected valid type for second argument");
4552+
45444553
// Both arguments must conform to FloatingPoint protocol.
45454554
if (!TypeChecker::conformsToKnownProtocol(firstArg->getType(),
45464555
KnownProtocolKind::FloatingPoint,

0 commit comments

Comments
 (0)