[Accepted with modifications] SE-0304: Structured Concurrency

Hello, Swift community.

When SE-0304 was accepted, the comment on withThrowingTaskGroup specified the following:

  • if the body returns normally:
    • the group will await any not yet complete tasks,
      • if any of those tasks throws, the remaining tasks will be cancelled,
    • once the withTaskGroup returns the group is guaranteed to be empty.

The third line here (about cancellation) has never been the implemented behavior of withThrowingTaskGroup. If you return normally from the body, all remaining tasks are awaited, and their results (whether normal or error) are discarded with no effect on the other tasks. Therefore we have a discrepancy between the proposal and its implementation.

(Note that the behavior of discarding task groups is intentionally different here.)

A member of the community recently pointed this out, and the Language Steering Group discussed it. The LSG believes that the appropriate response for now is to bring the proposal document in line with the current implementation. This is less a judgment about what the behavior should be and more a decision that too much time has passed to reasonably consider any change to be a mere bug fix. Adopting the originally-proposed semantics would now need to be separately proposed and reviewed. In the meantime, the proposal document should reflect reality.

John McCall
Language Steering Group

13 Likes