Skip to content

Commit 63286ae

Browse files
committed
[SILGen] Fix case emission when there are no case body vars
We want to call the `bodyEmitter`, since that has the extra logic necessary to handle `do-catch` statements. Previously this didn't cause any issues since `hasCaseBodyVariables` would have always been true for parsed `do-catch`s, but I'm planning on changing that.
1 parent 805b6d9 commit 63286ae

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2958,7 +2958,7 @@ void PatternMatchEmission::emitSharedCaseBlocks(
29582958
SWIFT_DEFER { assert(SGF.getCleanupsDepth() == PatternMatchStmtDepth); };
29592959

29602960
if (!caseBlock->hasCaseBodyVariables()) {
2961-
emitCaseBody(caseBlock);
2961+
bodyEmitter(caseBlock);
29622962
continue;
29632963
}
29642964

test/SILGen/pr-84149.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-emit-silgen %s -verify
2+
3+
enum E : Error {
4+
case a(Int), b(Int)
5+
}
6+
7+
func bar() throws {}
8+
9+
// Make sure we can correctly emit this without crashing.
10+
func foo() throws {
11+
do {
12+
try bar()
13+
} catch E.a, E.b {
14+
}
15+
}

0 commit comments

Comments
 (0)