SILGen: Fix break/continue inside 'for ... in ... repeat' loop

We were creating the JumpDests too early, so lowering a 'break' or 'continue'
statement would perform cleanups that were recorded while evaluating the
pack expansion expression, which would cause SIL verifier errors and
runtime crashes.

- Fixes https://github.com/swiftlang/swift/issues/78598
- Fixes rdar://131847933
This commit is contained in:
Slava Pestov
2025-11-10 11:17:10 -05:00
parent 3067602eb7
commit 522a6b7c80
14 changed files with 231 additions and 29 deletions

View File

@@ -597,9 +597,11 @@ public:
{&substEltType});
SGF.emitDynamicPackLoop(loc, inducedPackType, packComponentIndex,
openedEnv, [&](SILValue indexWithinComponent,
SILValue expansionPackIndex,
SILValue packIndex) {
openedEnv,
[]() -> SILBasicBlock * { return nullptr; },
[&](SILValue indexWithinComponent,
SILValue expansionPackIndex,
SILValue packIndex) {
componentInit->performPackExpansionInitialization(SGF, loc,
indexWithinComponent,
[&](Initialization *eltInit) {