Skip to content

Commit a92f617

Browse files
committed
[+0-all-args] When emitting for each statements, make sure to call unreachableExit from the Switch Case Scope.
This will allow me to enforce with an assert that the switch case scope is always exitted in an explicit way.
1 parent 797fe60 commit a92f617

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/SILGen/SILGenStmt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,10 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
867867

868868
// If we emitted an unreachable in the body, we will not have a valid
869869
// insertion point. Just return early.
870-
if (!SGF.B.hasValidInsertionPoint())
870+
if (!SGF.B.hasValidInsertionPoint()) {
871+
scope.unreachableExit();
871872
return;
873+
}
872874

873875
// Otherwise, associate the loop body's closing brace with this branch.
874876
RegularLocation L(S->getBody());

0 commit comments

Comments
 (0)