Skip to content

Complete switch lowering for multiple case-local breaks #172

Description

@Teakowa

Parent: #157
Discovered during: #170 / PR #171
Real-project evidence: Teakowa/Overwatch-AI-PVE@e0c0721 src/modules/hero_init/dispatcher.opy

Goal

Complete OPY switch lowering so ordinary multi-case switches with case-local break statements preserve OverPy observable semantics through canonical Workshop WIR.

Context

PR #171 advances the pinned OW1 project past its previous parser/catalog frontiers, but compilation now stops with unsupported-integration-surface:

multiple switch breaks with later reachable actions require canonical switch targets

The demonstrated real-project shape is a normal dispatch switch where each case performs actions and then breaks, for example:

switch eventPlayer.init_hero:
    case Hero.REAPER:
        heroInitReaper()
        break
    case Hero.TRACER:
        heroInitTracer()
        break

Current lowering can represent bounded switch/break shapes, but it rejects multiple case-local breaks when actions remain reachable after the first break because it lacks a correct shared switch-exit target. This is an opy-rs compiler/lowering gap, not a workshop-rs catalog or source-language syntax gap.

Scope

  • Support multiple case-local break statements in one OPY switch when later cases contain reachable actions.
  • Preserve ordinary case selection, fallthrough, default, and break semantics under the existing canonical Workshop WIR contract.
  • Preserve source provenance for the affected control-flow lowering and diagnostics.
  • Use the pinned OW1 dispatcher as real-project regression evidence in addition to minimized control-flow fixtures.
  • Re-run the affected compatibility/conformance and provider compile evidence after the root capability is fixed.

Non-goals

  • Adding OPY-specific switch/break nodes to workshop-rs solely to mirror source syntax.
  • Requiring compiler-output identity with upstream OverPy when canonical observable semantics are equivalent.
  • Weakening the compatibility/conformance baseline or retaining this demonstrated shape as a known gap.
  • General control-flow cleanup unrelated to the demonstrated switch-exit capability.

Acceptance criteria

  • A switch with multiple cases containing actions followed by break lowers successfully without unsupported-integration-surface.
  • Multiple case-local breaks target the correct shared logical switch exit; no later case action executes after a taken break.
  • Existing fallthrough/default and nested control-flow behavior remains correct under pinned oracle or equivalent independent evidence.
  • The pinned OW1 src/modules/hero_init/dispatcher.opy no longer fails at the multiple-switch-break boundary.
  • The pinned OW1 provider compile workflow is rerun and either produces an artifact or exposes the next independently demonstrated owner blocker.
  • Existing compatibility/conformance gates show no unexpected regression attributable to this change.
  • Independent implementation ablation that disables/simplifies the new shared switch-exit handling makes the relevant minimized and OW1 regression evidence fail again.

Ownership

  • OPY switch/break semantics and lowering: opy-rs.
  • Canonical Workshop WIR/validation/emission: workshop-rs.

Readiness

Ready. The failing source shape, owner boundary, and required observable behavior are demonstrated by the pinned real project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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