Skip to content

CMTK0003 misses a Task.WhenAny of Result tasks dropped without await #159

Closed

Description

@CaffeinatedCoder

Found while folding #157 into #152's fix.

Problem

Task.WhenAny over tasks of results, dropped as a statement without await, compiles with no CMTK0003, while every neighbouring form is reported:

Task.WhenAll(LoadAsync(), LoadAsync());          // CMTK0003, collection of Results
await Task.WhenAll(LoadAsync(), LoadAsync());    // CMTK0003, collection of Results
await Task.WhenAny(LoadAsync(), LoadAsync());    // CMTK0003, Result
Task.WhenAny(LoadAsync(), LoadAsync());          // no diagnostic

(LoadAsync() returns Task<Result<int, Fault>>.) Measured on fix/cmtk0003-wrapped-assertions with an analyzer test that expected exactly the three diagnostics above, which passed.

Cause

WhenAny returns Task<Task<Result<…>>>. DroppedOutcome looks one task deep (PendingOutcome), so it finds a Task<Result> and no outcome; awaited, the statement drops a Task<Result>, which it does find.

Release

Ships in 2.3.0, by the maintainer's decision of 2026-10-29, in one PR with #152 and #157. The form is written with APIs 2.2.0 already had, so 2.3.0 reports code that built on 2.2.0; decision 118 and the Analyzers README's "What a new version may change" name this exception.

Fix

Tasks.PendingOutcome sees a task of a task of a result, so a dropped WhenAny, its conversion to a plain Task and Wait on it are reported. ReturnsItsStoredReceiver takes Task.WhenAny of tasks the caller holds, which completes with one of them and drops nothing. That also stops await Task.WhenAny(held, other); being reported, as 2.2.0 did.

Activity

  1. added
    bug
    silent
    severity/low
    package/analyzers
    area/option-result
    on Oct 29, 2026
  2. added this to the 2.3.0 milestone on Oct 29, 2026
  3. changed the title [-]CMTK0003 misses a Task.WhenAny of Result tasks dropped without await (3.0.0: an Error that reports more)[/-] [+]CMTK0003 misses a Task.WhenAny of Result tasks dropped without await[/+] on Oct 29, 2026
  4. CaffeinatedCoder commented on Oct 29, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed in #164 (into release/2.3.0), held by DroppedTaskVariantTests over Variants/DroppedTaskShapes and seeded. The Analyzers README and the changelog say what 2.3.0 reports; 2.2-writable forms ship under decision 0119.

  5. CaffeinatedCoder commented on Oct 29, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed in #164, merged into release/2.3.0 (9878a6c).

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/option-resultbugpackage/analyzersseverity/lowsilent

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions