Skip to content

Commit a9fb330

Browse files
committed
Fix a crash in the ASTDumper
1 parent d113ca6 commit a9fb330

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,20 @@ namespace {
10331033
Indent -= 2;
10341034
}
10351035
}
1036+
10361037
if (D->hasSingleExpressionBody()) {
1037-
OS << '\n';
1038-
printRec(D->getSingleExpressionBody());
1039-
} else if (auto Body = D->getBody(/*canSynthesize=*/false)) {
1038+
// There won't be an expression if this is an initializer that was
1039+
// originally spelled "init?(...) { nil }", because "nil" is modeled
1040+
// via FailStmt in this context.
1041+
if (auto *Body = D->getSingleExpressionBody()) {
1042+
OS << '\n';
1043+
printRec(Body);
1044+
1045+
return;
1046+
}
1047+
}
1048+
1049+
if (auto Body = D->getBody(/*canSynthesize=*/false)) {
10401050
OS << '\n';
10411051
printRec(Body, D->getASTContext());
10421052
}

0 commit comments

Comments
 (0)