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
Error Sets #759
Merged
Merged
Error Sets #759
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to help track down accidentally linking against a library
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request removes the
%
prefix operator for making error unions. Instead we have the!
binary operator which makes an error union out of an error set and a payload type.The literal translation of
%T
to this new code iserror!T
.However this would not take advantage of error sets. It's
recommended to generally have all your functions which return possible
errors to use error set inference, like this:
Then you can return void, or any error, and the error set is inferred.
There's no more such thing as a top level error declaration, but you
can create explicit error sets like this:
The expression
error.Something
is syntactic sugar forerror{Something}.Something
.You're always allowed to implicitly cast an error from a subset to a superset.
error
is a superset of all error sets.You can get the compiler to tell you the possible errors for an inferred error set like this:
It's now recommended to generally leave off the
else
when switching on an error code.These sed commands should get you 90% through the transition that this change causes.
When we have automatic documentation generation, it will now be able to list all the possible errors that a given function can return, along with each error code's doc comments.
Closes #632