Skip to content

Tests: select await edge coverage (§14) #524

Closed

Description

@ehartford

Summary

Add missing edge-case tests for select await: zero arms and refutable branch patterns. Core select behavior has positive tests, but the requirement campaign found that the explicit negative rules are not covered. These tests protect the parser/sema boundary and make §14.10 diagnostics stable.

Spec

§14.10 requires at least one select await branch. Branch patterns are irrefutable bindings; refutable matching belongs inside the branch body.

select await:
    value = task => use(value)   // ok

select await:
    Some(value) = task => value  // error: refutable pattern

Current state

Sema rejects zero arms (src/SemaCheck.w:3353, src/SemaCheck.w:3357) and checks each branch task is awaitable (src/SemaCheck.w:3362, src/SemaCheck.w:3368). Parser lowering handles select branches in Parser.parse_select_await (src/Parser.w:4991). Existing positive tests cover branch selection, break, ?, fair and biased modes (test/spec/spec_ss14_9_select_await.w:16, test/spec/spec_ss14_10_fair_select_await.w:12).

There is no compile-error test proving zero-arm select or refutable branch patterns fail.

Implementation plan

  1. Add test/compile_errors/err_select_await_zero_arms.w with an empty braced or colon form and //! expect-error: select await requires at least one arm.
  2. Add test/compile_errors/err_select_await_refutable_pattern.w using a branch pattern such as Some(x) = task => ....
  3. If the parser cannot currently represent refutable branch patterns, make the test assert the parser diagnostic. If it parses but sema accepts it, add a sema check that the branch binder is an identifier/irrefutable binding only.
  4. Keep existing positive select await behavior tests unchanged.

Test plan

Run the two new compile-error tests plus existing select tests:

  • test/spec/spec_ss14_9_select_await.w;
  • test/spec/spec_ss14_10_fair_select_await.w;
  • test/behavior/behav_async_select.w;
  • test/behavior/behav_async_select_completed_loser_await.w.

Acceptance criteria

  • Zero-branch select await has a compile-error fixture.
  • Refutable branch pattern rejection has a compile-error fixture.
  • Positive select await tests continue to pass.
  • with build && with build :fixpoint && with build :test pass.

Dependencies

None.

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 14.10.1.15, 14.10.1.16.

Activity

  1. ehartford commented on Jul 3, 2026

    @ehartford
    ContributorAuthor

    Closing — select await with zero arms rejected, pinned by err_select_await_zero_arms (13f4f88). §14. Note: a refutable branch pattern is rejected only incidentally (generic parse error, no dedicated diagnostic) — surfaced for a possible diagnostic improvement, not pinned.

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