Skip to content

Commit 50c4b3f

Browse files
authored
Merge pull request swiftlang#32822 from CodaFi/totally-spaced-out
Handle Boolean Patterns Matching Against Invalid Constructor Forms
2 parents 00b3473 + 4369a71 commit 50c4b3f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Sema/TypeCheckSwitchStmt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ namespace {
412412
PAIRCASE (SpaceKind::BooleanConstant, SpaceKind::BooleanConstant):
413413
return this->getBoolValue() == other.getBoolValue();
414414

415+
PAIRCASE (SpaceKind::BooleanConstant, SpaceKind::Constructor):
415416
PAIRCASE (SpaceKind::BooleanConstant, SpaceKind::UnknownCase):
416417
return false;
417418

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
// N.B.: Requires a no-asserts build to reproduce, otherwise this hits an
4+
// assertion in type check pattern.
5+
// REQUIRES: no_asserts
6+
7+
indirect enum BadOverload {
8+
case one(Bool, other: Void)
9+
case one(Bool?)
10+
}
11+
12+
func crash(_ x: BadOverload) {
13+
switch $0 {
14+
case .one(false?):
15+
break
16+
}
17+
}
18+

0 commit comments

Comments
 (0)