paragonie / airship

Secure Content Management for the Modern Web - "The sky is only the beginning"
https://cspr.ng
Other
418 stars 41 forks source link

Use `Never` return type to declare function call is guaranteed to end program execution #203

Closed aidantwoods closed 6 years ago

aidantwoods commented 6 years ago

Summary

Inspired heavily by the introduction of this in Swift's standard library, introduce a non-constructible Never type to enforce that functions that are intended to end program execution actually do (not doing so would be a type error).

Issues Addressed (Optional)

n/a

Contributor Agreement (Required)

I am submitting this pull request under one or more of the following licenses:

Furthermore, I understand that CMS Airship is released under the GNU Public License to the general public, as well as private commercial licenses (purchasable from Paragon Initiative Enterprises).

By submitting this pull request, I acknowledge that my contribution will be incorporated into CMS Airship, and consent for it to be handled as outlined above.

(This does not in any way restrict your rights to use your own modifications. The purpose of this agreement is to maximize awareness and transparency.)

Labels Requested

Feel free to list any labels you feel are appropriate for this issue, and a member of the Airship core team will apply them as soon as possible.

paragonie-scott commented 6 years ago

Oh, this is interesting.

aidantwoods commented 6 years ago

Incidentally if you know how to make psalm happy without putting return statements in unreachable code let me know (I've tried @psalm-suppress InvalidReturnType in the docblock to no avail).