Navigation Menu

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-13489] Multiple trailing closures broken when omitting last optional closure? #55931

Closed
davidbjames opened this issue Sep 2, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@davidbjames
Copy link

Previous ID SR-13489
Radar None
Original Reporter @davidbjames
Type Bug
Status Closed
Resolution Done
Environment

Xcode 12 Beta 4

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 8a3fd5dca0fa0876e0c341c46f1d080c

Issue Description:

I am using Xcode 12 beta 4 and finding multiple trailing closures to be broken when omitting the last optional closure.

// Demonstrate single and multiple trailing closures.

// 1. Using the built-in UIView.animate()
// (same example used on SE-0279)

let view = UIView()
// Single trailing closure argument (works)
UIView.animate(withDuration: 0.3) {
  view.alpha = 0
}
// Multiple trailing closure arguments (works)
UIView.animate(withDuration: 0.3) {
  view.alpha = 0
} completion: { _ in
  view.removeFromSuperview()
}

// 2. Using a faked animate() with the same method signature
// as UIView.animate().

func animate(withDuration duration: TimeInterval, animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil) {
    
}

// Single trailing closure argument (does not work)
animate(withDuration:1.0) { // << ERROR
    view.alpha = 0.0
}
// Multiple trailing closure arguments (works)
animate(withDuration:1.0) {
    
} completion: { _ in
    
}

Error: Contextual type for closure argument list expects 1 argument, which cannot be implicitly ignored
Error: Missing argument for parameter 'animations' in call

@davidbjames
Copy link
Author

This bug is resolved on Xcode 12 beta 6.

@typesanitizer
Copy link

Thanks for checking!

@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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants