Skip to content

Commit c40efd4

Browse files
author
contraultra
committed
[SR-4978] Fix compiler crash for malformed ASTs
1 parent 8287835 commit c40efd4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/FrontendTool/ReferenceDependencies.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ bool swift::emitReferenceDependencies(DiagnosticEngine &diags,
256256
case DeclKind::Destructor:
257257
case DeclKind::EnumElement:
258258
case DeclKind::MissingMember:
259-
llvm_unreachable("cannot appear at the top level of a file");
259+
// These can occur in malformed ASTs.
260+
break;
260261
}
261262
}
262263

test/NameBinding/reference-dependencies-errors.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
// RUN: cp %s %t/main.swift
33
// RUN: not %target-swift-frontend -typecheck -primary-file %t/main.swift -emit-reference-dependencies-path - > %t.swiftdeps
44

5+
associatedtype Baz
6+
case bar
7+
deinit {}
58
extension Foo {}
9+
init() {}

0 commit comments

Comments
 (0)