Skip to content

Commit 4817bd4

Browse files
committed
Add some SourceKit crasher test cases
The unfixed ones were discovered by fuzzing. I have fixes for most of them in an in-progress PR. One that was already fixed is just a regression test I'm adding.
1 parent 5659f48 commit 4817bd4

14 files changed

+113
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
func matched<C: Collection>(atStartOf c: C)
5+
where C.Index#^A^# == Index {
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
let bounds: Range#^A^#
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
func searchTest(format: ()->String = { "" }#^A^#) {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
func _thread() {
5+
_ = #^A^#
6+
}
7+
8+
func run<InputCollection : Collection, Result>(_: InputCollection) -> Result {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A1 -source-filename=%s
2+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=B1 -source-filename=%s
3+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=C1 -source-filename=%s
4+
5+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A2 -source-filename=%s
6+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=B2 -source-filename=%s
7+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=C2 -source-filename=%s
8+
9+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A3 -source-filename=%s
10+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=B3 -source-filename=%s
11+
// REQUIRES: asserts
12+
13+
class a1<b#^A1^#> {}
14+
struct a2<b#^B1^#> {}
15+
enum a3<b#^C1^#> {}
16+
17+
class a4<b> where c == b#^A2^# {}
18+
struct a5<b> where c == b#^B2^# {}
19+
enum a6<b> where c == b#^C2^# {}yt
20+
21+
func f1<b#^A3^#> {}
22+
func f2<b>() where c == b#^B3^# {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
protocol a {
5+
associatedtype b
6+
}
7+
protocol c {
8+
associatedtype d : a
9+
}
10+
11+
struct e<f : c> where f == f.g.b {
12+
#^A^#
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
class D<X, Y>() {}
5+
6+
class C<T> {
7+
func f<U>() -> D<U, T> {}
8+
func g() {
9+
f#^A^#
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
.a != nil #^A^#
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
extension Integer {
5+
#^A^#
6+
extension {
7+
var : Self
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
Integer#^A^#
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
protocol a where #^A^#
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
4+
func a<b>(() -> b) -> b {
5+
a {}#^A^#
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
3+
extension Integer {
4+
init() {
5+
self = #^A^#
6+
}
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
3+
protocol MyDelegate: AnyObject {
4+
func mySweetDelegateFunction()
5+
}
6+
7+
class Foo {
8+
weak var delegate: MyDelegate?
9+
10+
func bar() {
11+
self.delegate.#^A^#
12+
// ^--- type "." here -> crash
13+
}
14+
}

0 commit comments

Comments
 (0)