0%

Canonicalizer: desugar with per-binding mutability

Goal

Desugar let? PAT = expr; + block rest into the two-arm match with a None-propagating terminating mismatch arm (try-boundary aware). The internal canonical pattern representation gains per-binding mutability so $ markers survive the desugar (match_pattern itself carries no $ - the desugar is definitional, not literal surface syntax). Exhaustiveness is trivially satisfied via the implicit wildcard arm.

Implementation Sketch

Scope contract: the approved proposal (compiler_repo/docs/ori_lang/proposals/approved/fallible-let-binding-proposal.md) - Design + Semantics + Spec & Grammar Impact sections govern this section verbatim; no scope invention. TDD: the failing test matrix for this section’s shapes lands before implementation; debug AND release verified at close.

Spec References

  • compiler_repo/docs/ori_lang/proposals/approved/fallible-let-binding-proposal.md
  • compiler_repo/docs/ori_lang/v2026/spec/16-control-flow.md (16.0.3, 16.5, 16.6, 16.7)
  • compiler_repo/docs/ori_lang/v2026/spec/15-patterns.md; 13-variables.md; grammar.ebnf

Work Items

  • Extend the canonical pattern representation with per-binding mutability
  • Desugar let? to the two-arm match with the None-propagation mismatch arm; final-statement empty-rest case yields void per 16.0.3
  • Canon tests: desugar shape, decision-tree integration, no E-exhaustiveness diagnostics from the implicit arm