Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14423] AsyncSequence.reduce should be throws not rethrows #56779

Closed
adam-fowler opened this issue Mar 30, 2021 · 2 comments
Closed

[SR-14423] AsyncSequence.reduce should be throws not rethrows #56779

adam-fowler opened this issue Mar 30, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@adam-fowler
Copy link

Previous ID SR-14423
Radar None
Original Reporter @adam-fowler
Type Bug
Status Closed
Resolution Invalid
Environment

Development snapshot 2021-03-25

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 5786b69d75e984f7125d0fe5c5610a4a

Issue Description:

AsyncSequence.reduce is currently tagged as rethrows

  public func reduce<Result>(
    _ initialResult: Result,
    _ nextPartialResult:
      (_ partialResult: Result, Element) async throws -> Result
  ) async rethrows -> Result {
    var accumulator = initialResult
    var iterator = makeAsyncIterator()
    while let element = try await iterator.next() {
      accumulator = try await nextPartialResult(accumulator, element)
    }
    return accumulator
  }

Shouldn't it be `throws` instead of `rethrows` as it calls

try await iterator.next()

I'm guessing this is the case for all the functions in that file

@xAlien95
Copy link
Contributor

AsyncSequence and AsyncIteratorProtocol are marked @rethrows. If I'm not mistaken, the effect of that attribute should be the one defined in this pitch (proposal available here).

@typesanitizer
Copy link

(Marked this as 'Resolved' since Stefano already explained how it works.)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

3 participants