Skip to content

[5.9] [Changelog] Add changelog entry for SE-0380 #65888

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

Merged
merged 1 commit into from
May 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ _**Note:** This is in reverse chronological order, so newer entries are added to

## Swift 5.9

* [SE-0380][]:

`if` and `switch` statements may now be used as expressions to:

* Return values from functions, properties, and closures (either with
implicit or explicit `return`)
* Throw errors using `throw`
* Assign values to variables
* Declare variables

Each branch of the `if` or `switch` must be a single expression, the value
of which becomes the value of the overall expression when that branch is
chosen.

```swift
let bullet =
if isRoot && (count == 0 || !willExpand) { "" }
else if count == 0 { "- " }
else if maxDepth <= 0 { "▹ " }
else { "▿ " }
```

```swift
public static func width(_ x: Unicode.Scalar) -> Int {
switch x.value {
case 0..<0x80: 1
case 0x80..<0x0800: 2
case 0x0800..<0x1_0000: 3
default: 4
}
}
```

* [#64927][]:

Swift 5.9 introduces warnings that catch conversions from an inout
Expand Down Expand Up @@ -9729,6 +9762,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
[SE-0370]: <https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
[SE-0376]: <https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
[SE-0377]: <https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md>
[SE-0380]: <https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md>

[#64927]: <https://github.com/apple/swift/issues/64927>
[#42697]: <https://github.com/apple/swift/issues/42697>
Expand Down