Skip to content

§14.10 (#2956): a select await arm races any async expression - #3018

Merged
ehartford merged 1 commit into
mainfrom
s14-10-select-recv-arm
Nov 3, 2026
Merged

ehartford merged 1 commit into
mainfrom
s14-10-select-recv-arm

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #2956.

An arm whose expression is not a Task (msg = rx.recv() => …, §14.10's first example) was refused with "select await arm requires a Task value". Now Sema records such an arm (select_arm_spawn_types, the Task[T] the select races) and binds the arm's name to the expression's own type; MIR lowers the expression as an async block whose body is the expression (lower_async_body, shared with NK_ASYNC_BLOCK), so the existing select, await, cancel and cleanup protocol sees a Task and codegen spawns the fiber from the same constant an async block uses. No codegen change. A loser parked in recv() is cancelled at that suspension as before. A Task-typed expression the checker cannot await still gets the refusal, now naming the arm's type.

Fixtures: the open conformance fixture moves to test/behavior (a receive racing a task parked on a quiet channel; the loser unwinds and its channel is untouched); a second races two receivers across two selects. The conformance row flips to implemented.

Iterate tier: both fixtures failed on the installed compiler; on the stage1 they pass, --validate-all: ok, the 51 async/channel/select behavior fixtures pass, ceremony census diff ok. Gate green (412 s). Draft until the battery is green.

An arm whose expression is not a Task (`msg = rx.recv() => ...`, the
spec's first example) was refused: "select await arm requires a Task
value". Now Sema records such an arm (`select_arm_spawn_types`, the
Task[T] the select races) and binds the arm's name to the expression's
own type; MIR lowers the expression as an async block whose body is the
expression (`lower_async_body`, shared with NK_ASYNC_BLOCK, through
`prepare_anonymous_body_of`), so the existing select, await, cancel and
cleanup protocol sees a Task and codegen spawns the fiber from the same
constant an async block uses. A loser parked in recv() is cancelled at
that suspension as before. A Task-typed expression the checker cannot
await still gets the refusal, now naming the arm's type.

Fixtures: the open conformance fixture moves to test/behavior (a receive
racing a parked task); a second races two receivers across two selects.
The conformance row flips to implemented.
@ehartford
ehartford marked this pull request as ready for review November 3, 2026 14:56
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green on 6474f30 (seed-driven: gate, uat, battery-checks; out/battery/battery.log rc=0 green). Drop audit green.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

§14.10: a channel receive as a select await arm (the spec's example) is refused: "select await arm requires a Task value"

1 participant