mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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.
This commit is contained in:
@@ -2958,7 +2958,7 @@ void PatternMatchEmission::emitSharedCaseBlocks(
|
||||
SWIFT_DEFER { assert(SGF.getCleanupsDepth() == PatternMatchStmtDepth); };
|
||||
|
||||
if (!caseBlock->hasCaseBodyVariables()) {
|
||||
emitCaseBody(caseBlock);
|
||||
bodyEmitter(caseBlock);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
15
test/SILGen/pr-84149.swift
Normal file
15
test/SILGen/pr-84149.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: %target-swift-emit-silgen %s -verify
|
||||
|
||||
enum E : Error {
|
||||
case a(Int), b(Int)
|
||||
}
|
||||
|
||||
func bar() throws {}
|
||||
|
||||
// Make sure we can correctly emit this without crashing.
|
||||
func foo() throws {
|
||||
do {
|
||||
try bar()
|
||||
} catch E.a, E.b {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user