Skip to content
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

[SR-832] Nil coalescing operator can't be applied to optional closures #43444

Closed
swift-ci opened this issue Feb 26, 2016 · 1 comment
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-832
Radar None
Original Reporter py (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 7.2.1

Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee @gregomni
Priority Medium

md5: 7fe43bb255e2d27716d25ed3a7e3458d

Issue Description:

As the attached screenshot and playground demonstrates, it's not possible to use the nil coalescing operator on an optional closure, despite being able to use the longhand ternary version to achieve the same thing.

func someFunc(foo: (String -> String)?, bar: String -> String) {
    let baz: String -> String = foo != nil ? foo! : bar // Allowed
    let quux: String -> String = foo ?? bar // Not allowed
}
@gregomni
Copy link
Collaborator

gregomni commented Mar 1, 2016

Fixed in commit 88c6cdb

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants