Skip to content

Lower guarded equations, guarded case alternatives, and multi-scrutinee case #88

Closed

Description

@biuld

Part of #75 (Phase 2). 12 passing files stop on guards and multi-scrutinee case, and two more M2 failing cases (LetPatterns2.purs, OverlappingBinders.purs) depend on the same machinery.

Scope

  • Guarded equations — f x | p = e (5 files: passing/2787.purs, passing/2806.purs, passing/DctorName.purs, passing/FunctionAndCaseGuards.purs, passing/TCO.purs).
  • Guarded case alternatives — alt | p -> e (5 files: passing/2795.purs, passing/3114/VendoredVariant.purs, passing/4357.purs, passing/Guards.purs, passing/MultiArgFunctions.purs).
  • Comma-separated guard lists — alt | a, b -> e. The parser already accepts these (parse_guard_list skips Comma at crates/psrs-syntax/src/parser/declaration/mod.rs:137), so this is lowering only.
  • let and pattern guards — | Just x <- action, | let y = e.
  • Multiple scrutinees — case a, b of (passing/CaseMultipleExpressions.purs, passing/CaseInputWildcard.purs).

Current diagnostic split

The AST layer reports distinct messages — "guarded case alternatives are not supported yet" and "guarded equations are not supported yet" — so the blocker is localized and the two forms are tracked separately today.

Design note

A guard is a filter on an alternative, and case a, b of is a tuple scrutinee plus per-alternative pattern matching. Both reduce cleanly onto the existing decision DAG: guards become additional decision rows that must all succeed, and multiple scrutinees become a shared scrutinee representation. Neither should need a new CC or MIR form — which is why this belongs before Phase 5 rather than in it.

Acceptance

Both guard forms lower with comma lists, let/pattern guards, and multi-scrutinee case; exhaustiveness and redundancy analysis account for guards.

Activity

  1. added
    gate:L2Blocks module, import, export and name resolution (D-04 L2)
    area:frontendFrontend: syntax, resolution, kinds, types, classes
    on Oct 1, 2026
  2. added a commit that references this issue on Oct 2, 2026
  3. biuld commented on Oct 2, 2026

    @biuld
    OwnerAuthor

    Acceptance verified and reconciled in PR #116 (f2490ef), following the implementation in PR #113 and the shared pattern coverage in #115. Full workspace tests ran with PSRS_REQUIRE_WASMTIME=1; fmt, clippy, upstream differential 4/4, full annotations/runtime scoreboards 5/5 and both required remote Wasmtime checks passed. All 12 named official fixtures lower through P2; the M2 annotated LetPatterns2 and OverlappingBinders cases agree. New matrix and driver regressions prove guarded rows do not establish coverage or shadow each other, report the exact source span of a row shadowed by unconditional coverage, and execute first-match/fallthrough results 11 and 22. purs reports OverlappingPattern for the corresponding redundant Boolean row. D-04 and PM-14 now record the complete issue-scope evidence, retaining broader FE-06/M7 runtime blockers separately: official runtime is 0/413 and named cases still need library modules. Corpus cases refreshed to the measured 22 P2 recoveries attributed to this slice in D-04.

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

    area:frontendFrontend: syntax, resolution, kinds, types, classesenhancementNew feature or requestgate:L2Blocks module, import, export and name resolution (D-04 L2)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions