Skip to content

Commit ef2995b

Browse files
committed
Add CHANGELOG.md entry describing previous rethrows checking change and subsequent relaxation
1 parent f1831fb commit ef2995b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ CHANGELOG
2929
Swift 5.5
3030
---------
3131

32+
* The determination of whether a call to a `rethrows` function can throw now considers default arguments of `Optional` type.
33+
34+
In Swift 5.4, such default arguments were ignored entirely by `rethrows` checking. This meant that the following example was accepted:
35+
36+
```swift
37+
func foo(_: (() throws -> ())? = nil) rethrows {}
38+
foo() // no 'try' needed
39+
```
40+
41+
However, it also meant that the following was accepted, even though the call to `foo()` can throw and the call site is not marked with `try`:
42+
43+
```swift
44+
func foo(_: (() throws -> ())? = { throw myError }) rethrows {}
45+
foo() // 'try' *should* be required here
46+
```
47+
48+
The new behavior is that the first example is accepted because the default argument is syntactically written as `nil`, which is known not to throw. The second example is correctly rejected, on account of missing a `try` since the default argument *can* throw.
49+
3250
* [SE-0293][]:
3351

3452
Property wrappers can now be applied to function and closure parameters:

0 commit comments

Comments
 (0)