Skip to content

[Diagnostics] Port explicit closure result contextual mismatch #28240

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 2 commits into from
Nov 14, 2019

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Nov 13, 2019

Detect and diagnose a problem when explicitly specified closure
result type doesn't match what is expected by the context:

Example:

func foo(_: () -> Int) {}

foo { () -> String in "" } // `Int` vs. `String`

Detect and diagnose a problem when explicitly specified closure
result type doesn't match what is expected by the context:

Example:

```swift
func foo(_: () -> Int) {}

foo { () -> String in "" } // `Int` vs. `String`
```
@xedin xedin requested a review from hborla November 13, 2019 22:07
@xedin
Copy link
Contributor Author

xedin commented Nov 13, 2019

This is also related to diagnoseGeneral*Failure removal from CSDiag.

@xedin
Copy link
Contributor Author

xedin commented Nov 13, 2019

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Nov 13, 2019

@swift-ci please smoke test macOS platform

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Nov 14, 2019

@swift-ci please smoke test macOS platform

@@ -656,8 +656,8 @@ func sr4214() {
let closure = { val in val.x = 7 } as (inout MutableSubscripts) -> () // Ok
var v = MutableSubscripts()
closure(&v)
// FIXME: This diagnostic isn't really all that much better
// expected-error@+1 {{cannot convert value of type '(inout MutableSubscripts) -> ()' to expected argument type '(_) -> _'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@xedin xedin merged commit edaf7b0 into swiftlang:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants