Repository navigation
Description
Summary
Collection-await coverage is still incomplete, and current probes expose three
live correctness/compiler failures:
- await_first returns the first input, not the first completed task.
- await_any returns the first successful input, not the first successful
completion. - the fallible await_all overload is not usable through the specified public
surface; the question-mark form reaches an internal compiler BUG.
Some cancellation coverage landed after this issue was filed, so the old
“no focused collection-combinator test” premise is no longer true.
Current evidence (2026-07-15)
The existing
test/spec/spec_ss14_11_await_combinator_cancel_joins.w (f915adf) verifies that
cancelling a parent while each combinator is running cancels and joins its
children. It passes on the current compiler. It does not cover normal early
return, completion ordering, empty inputs, or the public result contracts.
A single current matrix used a slow first task (three suspension ticks) and an
immediately-ready second task:
all=10,20
first=10
any_ok=10
any_errors=e10,e20
any_empty=0
settled0=ok10
settled1=e20
The expected first/any winners are 20. The other displayed ordering and
empty-input cases conform.
The implementation matches the failure:
- await_first always awaits pending.get(0);
- await_any awaits pending entries sequentially and returns the first indexed
Ok; - neither observes which task actually completes first.
The fallible await_all surface has a separate generic-call problem. Given
Vec[Task[Result[i32, str]]]:
-
returning tasks |> await_all as Result[Vec[i32], str] selects/involves the
wrong contract and produces return-type mismatch diagnostics; -
using the specified tasks |> await_all? form exits 134 with:
BUG: user generic call lacks a concrete contract [src/MirLower.w:13113 MirModule.validate_generic_call_contracts]
The empty await_first contract does work: it exits 134 with the stable
“await_first: empty input” panic.
docs/requirements.md currently marks the collection-await requirements
complete while linking this still-open tracker. Those checkmarks do not match
the observed behavior.
Work
- Implement completion-aware selection for await_first and await_any. Input
ordering may determine deterministic tie-breaking, but cannot replace
completion ordering. - Make the fallible await_all signature callable exactly as specified,
including the pipeline/question-mark form, without an internal compiler
abort. - Add one focused §14.11 suite covering:
- infallible await_all input order despite different completion order;
- fallible await_all fail-fast when a later input errors before an earlier
nonterminating/cooperatively-suspending task; - await_first winner selection and loser cancellation/join;
- await_any first Ok, all-fail input-order errors, and empty input;
- await_settled input order and no early cancellation;
- combinator-parent cancellation (retain the existing f915adf coverage).
- Use live-fiber/cancellation hooks to prove losers have stopped before an
early-return combinator returns. - Correct requirements traceability after the tests genuinely cover each
checked requirement.
Do not weaken the tests to the current input-sequential implementation. The
specification leads the stdlib.
Acceptance criteria
- A slower first input and faster second input make await_first return the
second value. - await_any returns the earliest successful completion, not the lowest input
index containing Ok. - A later fast Err makes fallible await_all cancel/join an earlier suspended
task and return the Err. - All-fail errors and settled/all values remain in input order.
- Empty await_first and await_any match their documented contracts.
- Early return and parent cancellation both restore the live-fiber baseline.
- No supported call form reaches a compiler BUG or generic-contract panic.
- Full build, fixpoint, audit, and test gates pass.
Traceability
- Specification §14.11 and §14.11.1
- docs/requirements.md 14.11.1.14–17, 14.11.1.21–39
- Related compiler seam: Generic async function monomorphization silently returns wrong values #558
Activity
[-]Tests: collection await coverage (§14)[/-][+]std.task collection combinators: completion ordering, fallible await_all, and coverage[/+]std.task: #489 collection-await correctness; E0921 evidence at call s…
ehartford commentedon Jul 15, 2026
Implemented in eafb4ed (§14.11.1).
Behavior
await_all(Task[T])andawait_all(Task[Result[T, E]])(same-name generic overloads, selected structurally — including the pipedtasks |> await_all?spelling),await_first,await_any,await_settled.spec_ss14_11_collection_await.wpins that case (later input completing first winsawait_first/await_any).await_allreturns the first completion-observedErrand cancel/joins unfinished siblings via a defer;await_first/await_anyjoin losers before returning; all-failawait_anyerrors are input-ordered;await_settlednever cancels.task_cancel_point().await) sits inside each combinator's own frame;spec_ss14_11_await_combinator_cancel_joins.wcancels a parent inside all five combinators and asserts the live-fiber baseline is restored.behav_await_first_empty_panics.w(exit 134, stderrawait_first: empty input);await_any([])returnsErr(Vec.new())in the spec fixture.Compiler prerequisites (same commit)
?on a pipeline stage reparents over the completed pipeline (Parser.build_forward_pipeline), covered bybehav_pipeline.w.behav_generic_overload.w.async fn task_cancel_pointexposed that concurrency evidence was declaration-based, failing every ZCU with a mutable global (offset-proven to lib/std/task.w:27;use std.timealone already reproduced the same defect on the released compiler). Evidence is now recorded at call/reference sites per §9.1's usage-based obligation — docs/decisions.md D9. Verified by matrix: uncalled decls clean; direct/generic/method/dyn/fn-value calls, async blocks, and instantiated combinator internals all still fail the proof.Gates (all on eafb4ed's tree)
with buildexit 0;:fixpointFIXPOINT;analyze src/main.w audit:allviolations=0:testGATES EXIT 0 (866 behavior / 703 compile-error / 210 spec / all remaining targets green, EMIT-C smoke ok);:test-greenand:last-greenrecordedstrpayloads across extraction, fail-fast, completed-loser cleanup, parent cancellation): no new-slice leaks or double-frees; every reported leak is the POD Vec[i32] buffer never freed at scope exit (debug-allocator finding) #608-pinned by-design POD-Vec backing state.Notes
slot.set(Some(x))in generic bodies is sema-typed as the payload → codegen trap; task.w carries commented typed intermediates to remove with the fix.--target x86_64-pc-windows-msvc --no-prelude --validate-all) but has not been executed on a Windows host.