Skip to content

Commit f7e778f

Browse files
authored
Merge pull request #24590 from DougGregor/pattern-type-check-crash-5.1
[5.1] [Type checker] Fix a crash-on-invalid in pattern type checking.
2 parents 3007c4a + 6ec08ba commit f7e778f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,10 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
14381438
}
14391439
}
14401440
}
1441+
1442+
if (!elt)
1443+
return true;
1444+
14411445
enumTy = type;
14421446
} else {
14431447
// Check if the explicitly-written enum type matches the type we're
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
open class Foo {
4+
open class func foo<T: Equatable>(value: T?, other: T?) {
5+
switch (value, other) {
6+
case (.some(let unwrappedValue &), .none): // the & here triggers it
7+
fallthrough
8+
default:
9+
fatalError()
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)