# Typed throw functions

**URL:** <https://forums.swift.org/t/typed-throw-functions/38860>\
**Category:** Discussion\
**Tags:** throw, swift, error\
**Created:** [July 29, 2020, 11:34am UTC](https://forums.swift.org/t/typed-throw-functions/38860 "2020-07-29T11:34:11Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [July 31, 2020, 8:44am UTC](https://forums.swift.org/t/typed-throw-functions/38860/28 "2020-07-31T08:44:30Z")

</div>

I don't know if it was already mentioned upthread or not, but one of the reasons I want typed throws is exactly this:

> [@Pitch: Genericizing over annotations like throws](https://forums.swift.org/t/pitch-genericizing-over-annotations-like-throws/20376/10):
>
> Another interesting future direction we could take to address polymorphism over throws specifically would be to adopt typed throws, and make the error type an independent type argument of all function types. This would mean that a type that doesn't throw effectively throws Never, and one that throws without a type by default throws Error: (X, Y, Z) -\> W === (X, Y, Z) throws Never -\> W (X, Y, Z) throws -\> W === (X, Y, Z) throws Error -\> W This would allow protocols to be generic over thr…

This would also beautifully fit with throwing accessors:

> [@Throwable accessors](https://forums.swift.org/t/throwable-accessors/20509):
>
> I have spent a bit of time looking into this based on @John_McCall suggestion and encouragement [here](https://forums.swift.org/t/proposal-allow-getters-and-setters-to-throw/191/20). I think the first thing is to start with the parser and update parseGetSet() to consume a throws token and then update createAccessorFunc() signature to accept a throws boolean so when creating an AccessorDecl, we can pass it forward. I have started working on this feature, but I am wondering how much code can be reused since AccessorDecl is a subclass of FuncDecl which supports throws and wha…

---

_[View the full topic](https://forums.swift.org/t/typed-throw-functions/38860)._
