Skip to content

Commit 1dad0f8

Browse files
authored
Merge pull request #39124 from hborla/repair-failures-crash
[ConstraintSystem] Fix a silly crash in `repairFailures`.
2 parents 1907a82 + d2bdbd6 commit 1dad0f8

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4761,7 +4761,7 @@ bool ConstraintSystem::repairFailures(
47614761
path.pop_back();
47624762

47634763
// Drop the tuple type path elements too, but extract each tuple type first.
4764-
if (path.back().is<LocatorPathElt::TupleType>()) {
4764+
if (!path.empty() && path.back().is<LocatorPathElt::TupleType>()) {
47654765
rhs = path.back().getAs<LocatorPathElt::TupleType>()->getType();
47664766
path.pop_back();
47674767
lhs = path.back().getAs<LocatorPathElt::TupleType>()->getType();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend -typecheck -verify %s
2+
3+
struct S {
4+
private let data: [[String]]
5+
private func f() {}
6+
7+
func test() {
8+
// expected-error@+1 {{static method 'buildBlock' requires that 'ForEach<[String], ()>' conform to 'View'}}
9+
ForEach(data) { group in
10+
ForEach(group) { month in
11+
self.f()
12+
}
13+
}
14+
}
15+
}
16+
17+
struct Wrapper<T> {}
18+
19+
protocol View {}
20+
21+
@resultBuilder struct Builder {
22+
// expected-note@+1 {{where 'Content' = 'ForEach<[String], ()>'}}
23+
static func buildBlock<Content: View>(_ content: Content) -> Content { fatalError() }
24+
}
25+
26+
struct ForEach<Data, Content> where Data : RandomAccessCollection {
27+
init<C>(_ data: Wrapper<C>, @Builder content: (Wrapper<C.Element>) -> Content) where C : MutableCollection {}
28+
init(_ data: Data, @Builder content: @escaping (Data.Element) -> Content) {}
29+
}

0 commit comments

Comments
 (0)