Skip to content

Commit c999f62

Browse files
committed
Add fixed crasher from SR-5905.
1 parent 0609785 commit c999f62

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: not %target-swift-frontend %s -typecheck
2+
protocol VectorIndex {
3+
associatedtype Vector8 : Vector where Vector8.Index == Self, Vector8.Element == UInt8
4+
}
5+
enum VectorIndex1 : VectorIndex {
6+
case i0
7+
typealias Vector8 = Vector1<UInt8>
8+
}
9+
protocol Vector {
10+
associatedtype Index: VectorIndex
11+
associatedtype Element
12+
init(elementForIndex: (Index) -> Element)
13+
subscript(index: Index) -> Element { get set }
14+
}
15+
struct Vector1<Element> : Vector {
16+
//typealias Index = VectorIndex1 // Uncomment this line to workaround bug.
17+
var e0: Element
18+
init(elementForIndex: (VectorIndex1) -> Element) {
19+
e0 = elementForIndex(.i0)
20+
}
21+
subscript(index: Index) -> Element {
22+
get { return e0 }
23+
set { e0 = newValue }
24+
}
25+
}
26+
extension Vector where Index == VectorIndex1 {
27+
init(_ e0: Element) { fatalError() }
28+
}

0 commit comments

Comments
 (0)