Skip to content

Commit 965b970

Browse files
committed
Top-level code doesn't have a catch context, and that's okay
1 parent 6bd39db commit 965b970

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,16 +1025,14 @@ class Verifier : public ASTWalker {
10251025
SourceLoc loc = S->getThrowLoc();
10261026
if (loc.isValid()) {
10271027
auto catchNode = ASTScope::lookupCatchNode(getModuleContext(), loc);
1028-
1029-
if (!catchNode) {
1030-
Out << "No catch context for throw statement\n";
1031-
abort();
1032-
}
1033-
1034-
if (auto thrown = catchNode.getThrownErrorTypeInContext(Ctx)) {
1035-
thrownError = *thrown;
1028+
if (catchNode) {
1029+
if (auto thrown = catchNode.getThrownErrorTypeInContext(Ctx)) {
1030+
thrownError = *thrown;
1031+
} else {
1032+
thrownError = Ctx.getNeverType();
1033+
}
10361034
} else {
1037-
thrownError = Ctx.getNeverType();
1035+
thrownError = checkExceptionTypeExists("throw expression");
10381036
}
10391037
} else {
10401038
return;

0 commit comments

Comments
 (0)