Skip to content

Commit efefc23

Browse files
committed
Mark updates needed in the reference
1 parent 7ecd269 commit efefc23

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

TSPL.docc/ReferenceManual/Declarations.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,8 +1468,16 @@ func <#function name#>(<#parameters#>) throws -> <#return type#> {
14681468
Calls to a throwing function or method must be wrapped in a `try` or `try!` expression
14691469
(that is, in the scope of a `try` or `try!` operator).
14701470

1471+
<!-- XXX
1472+
Rule for inferring the thrown error type
1473+
Xref to the guide <doc:ErrorHandling#Specifying-a-Concrete-Error-Type>
1474+
-->
1475+
14711476
The `throws` keyword is part of a function's type,
14721477
and nonthrowing functions are subtypes of throwing functions.
1478+
<!-- XXX
1479+
Subtyping rule for throws(any Error) vs throws(MyErrorType)
1480+
-->
14731481
As a result, you can use a nonthrowing function
14741482
in a context where a throwing one is expected.
14751483

TSPL.docc/ReferenceManual/Expressions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,10 @@ explicitly marks a closure as throwing or asynchronous.
924924

925925
If the body of a closure includes a try expression,
926926
the closure is understood to be throwing.
927+
<!-- XXX
928+
The same rule to infer the thrown error type
929+
applies to closures as to functions.
930+
-->
927931
Likewise, if it includes an await expression,
928932
it's understood to be asynchronous.
929933

TSPL.docc/ReferenceManual/Statements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ or the boxed protocol type `any Error`.
897897
If the `do` statement doesn't specify the type of error it throws,
898898
that type is implied to be `any Error`.
899899
For more information about working with errors that have explicit types,
900-
see <!-- XXX xref guide -->.
900+
see <doc:ErrorHandling#Specifying-a-Concrete-Error-Type>.
901901

902902
If any statement in the `do` code block throws an error,
903903
program control is transferred

TSPL.docc/ReferenceManual/Types.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,14 @@ Function types for functions
350350
that can throw or rethrow an error must be marked with the `throws` keyword.
351351
The `throws` keyword is part of a function's type,
352352
and nonthrowing functions are subtypes of throwing functions.
353+
<!-- XXX
354+
A function that throws a concrete error
355+
is a subtype of one that throws 'any Error'.
356+
357+
TR:
358+
If EE is a subtype of E,
359+
is a function that throws EE a subtype of one that throws E?
360+
-->
353361
As a result, you can use a nonthrowing function in the same places as a throwing one.
354362
Throwing and rethrowing functions are described in
355363
<doc:Declarations#Throwing-Functions-and-Methods>

0 commit comments

Comments
 (0)