prometeu-studio/docs/pbs/pull-requests/PR-014-pbs-switch-wildcard-rules.md
2026-03-24 13:42:21 +00:00

1.1 KiB

PR-014 - PBS Switch Wildcard Rule Enforcement

Briefing

Switch semantics do not currently enforce all wildcard constraints. This PR enforces: at most one wildcard arm, and rejection of mixed default and _ in the same switch.

Motivation

Wildcard ambiguity weakens deterministic static semantics and conformance.

Target

  • Switch expression semantic validation in flow analyzer.
  • Required static diagnostics for wildcard rule violations.

Scope

  • Enforce wildcard-count and wildcard-mixing rules.
  • Preserve existing selector/type compatibility checks.

Method

  • Track wildcard token form used per switch arm.
  • Emit diagnostics for duplicate wildcard and mixed wildcard spellings.
  • Keep existing exhaustiveness behavior.

Acceptance Criteria

  • Two wildcard arms are rejected deterministically.
  • default + _ in one switch is rejected deterministically.
  • Existing duplicate-pattern logic for non-wildcards remains unchanged.

Tests

  • Add tests for duplicate wildcard arms.
  • Add tests for mixed default/_ arms.
  • Run semantic control-flow suite.

Non-Goals

  • New switch syntax.
  • Runtime switch lowering changes.