@@ -1246,8 +1246,6 @@ void StmtEmitter::visitRepeatWhileStmt(RepeatWhileStmt *S) {
1246
1246
}
1247
1247
1248
1248
void StmtEmitter::visitForEachStmt (ForEachStmt *S) {
1249
- // Emit the 'iterator' variable that we'll be using for iteration.
1250
- LexicalScope OuterForScope (SGF, CleanupLocation (S));
1251
1249
1252
1250
if (auto *expansion =
1253
1251
dyn_cast<PackExpansionExpr>(S->getTypeCheckedSequence ())) {
@@ -1257,7 +1255,6 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
1257
1255
1258
1256
JumpDest loopDest = createJumpDest (S->getBody ());
1259
1257
1260
- // Set the destinations for 'break' and 'continue'.
1261
1258
JumpDest endDest = createJumpDest (S->getBody ());
1262
1259
1263
1260
SGF.emitDynamicPackLoop (
@@ -1271,6 +1268,7 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
1271
1268
1272
1269
SGF.emitExprInto (expansion->getPatternExpr (), letValueInit.get ());
1273
1270
1271
+ // Set the destinations for 'break' and 'continue'.
1274
1272
SGF.BreakContinueDestStack .push_back ({S, endDest, loopDest});
1275
1273
visit (S->getBody ());
1276
1274
SGF.BreakContinueDestStack .pop_back ();
@@ -1284,6 +1282,8 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
1284
1282
return ;
1285
1283
}
1286
1284
1285
+ // Emit the 'iterator' variable that we'll be using for iteration.
1286
+ LexicalScope OuterForScope (SGF, CleanupLocation (S));
1287
1287
SGF.emitPatternBinding (S->getIteratorVar (),
1288
1288
/* index=*/ 0 , /* debuginfo*/ true );
1289
1289
0 commit comments