@@ -889,13 +889,31 @@ do throws(<#type#>) {
889889}
890890```
891891
892+ <!-- XXX Is " do throws { }" allowed? -->
893+
892894If the `do ` statement includes a `throws ` clause,
893- the `do ` block can throw only errors of the specified type.
894- The * type* must be a concrete type that conforms to the `Error ` protocol,
895+ the `do ` block can throw errors of only the specified * type* .
896+ The * type* must be either
897+ a concrete type that conforms to the `Error ` protocol,
895898an opaque type that conforms to the `Error ` protocol,
896899or the boxed protocol type `any Error`.
897900If the `do` statement doesn't specify the type of error it throws,
898- that type is implied to be `any Error`.
901+ the error type is inferred as follows:
902+
903+ - If every `throws` statement and `try` expression in the `do` code block
904+ is nested inside of an exhaustive error handling mechanism,
905+ then the `do` statement is inferred as nonthrowing.
906+
907+ - If the `do` code block contains code that throws
908+ errors of only a single type
909+ outside of exhaustive error handling,
910+ then the `do` statement is inferred as throwing that concrete error type.
911+
912+ - If the `do` code block contains code that throws
913+ errors of more than a single type
914+ outside of exhaustive error handling,
915+ then the `do` statement is inferred as throwing `any Error`.
916+
899917For more information about working with errors that have explicit types,
900918see <doc:ErrorHandling #Specifying -a -Concrete -Error -Type >.
901919
0 commit comments