Skip to content

async labeled switch with await spins forever at break label #9186

Closed

Description

@proggeramlug

Release blocker

Full-tier CI run 33317606566 timed out in cargo-test-perry (8/8) after 120 minutes. The exact stuck test is:

issue_5868_switch_state_machine::labeled_switch_break_label

The test reached break l after its awaited console.log, then the generated binary consumed CPU indefinitely. The seven other Perry integration shards passed.

Minimal repro

async function run() {
  l: switch (1) {
    case 1:
      console.log(await Promise.resolve("in-case"));
      break l;
    case 2:
      console.log("no");
  }
  console.log("after");
}
run();

Expected:

in-case
after

Actual: generated binary spins forever.

Root-cause evidence

HIR tracing on release candidate 7f1ae8b33ad971460502bd3c127d2820a7762650 shows state 4 still contains LabeledBreak("l"). Source lowering represents a labeled non-loop statement as a labeled run-once do ... while(false). Generator linearization drops that label wrapper while linearizing its yielding loop, but rewrite_labeled_bc_in_stmts deliberately does not rewrite a targeted labeled break inside a nested switch. The later yielding-switch desugar therefore preserves an unresolved labeled break, and state-machine codegen falls back to the dispatch loop target and spins.

Acceptance criteria

  • The existing labeled_switch_break_label integration test completes with in-case\nafter\n.
  • Post-transform HIR no longer leaves the source LabeledBreak("l") unresolved in the async dispatch states.
  • Preserve switch-local break behavior and outer-label break behavior when a yielding switch is nested in a labeled loop/run-once wrapper.
  • The full Perry integration shard 8 completes within its CI budget.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions