Detect if an async sequence throws or not?

I know this is still an underdeveloped area of Swift (@rethrows, typed throws, etc.), but I came across this clever trick in swift-async-algorithms for propagating rethrows, and was wondering if anyone had discovered ways to get the compiler to detect if a given async sequence is throwing or not, ideally at compile time?


The compiler definitely has the info for knowing if it does or not. But there is no exposition of that.

What you might be looking for is called "generic effects"; where the effects (throws, async etc) applied to a function or type are able to participate in generic signatures. Sadly that does not yet exist and is a monster hiding under the waters - it is way more complicated than just what this part exposes.


That's what I figured, but was hoping some dark magic existed :smiley:

Looking forward to seeing this story get fleshed out in the future!

1 Like