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-10266] Unhelpful error message around trying in a non-throwing closure #52666

Closed
stephencelis opened this issue Apr 2, 2019 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@stephencelis
Copy link
Contributor

Previous ID SR-10266
Radar None
Original Reporter @stephencelis
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Swift 5 / Xcode 10.2

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

md5: de35bcfe0edb238fbaebae7ee839fb5b

Issue Description:

Paste the following into a playground.

struct PredicateSet<A> {
  let contains: (A) -> Bool

  func pullback<B>(_ f: @escaping (B) -> A) -> PredicateSet<B> {
    return PredicateSet<B>(contains: { b in self.contains(f(b)) })
  }
}


import Foundation

let p = PredicateSet<Data>(contains: { data in data.first == 0 })
let q: PredicateSet<URL> = p.pullback { url in try Data(contentsOf: url) } 

And get the following error on the last line:

Cannot convert value of type '_' to closure result type 'Data'

Force-try!-ing will let things compile, but it'd be nice to have better error messaging here. For example, in a plain ole function that isn't throwing, we get this nice error message:

Errors thrown from here are not handled

@belkadan
Copy link
Contributor

belkadan commented Apr 2, 2019

cc @xedin

@LucianoPAlmeida
Copy link
Collaborator

@stephencelis This seems fixed on XCode 11.4 and it seems fixed(as in the snapshot), can you verify and close? 🙂

![](Screen Shot 2020-03-19 at 20.57.30.png)

@stephencelis
Copy link
Contributor Author

Looks fixed

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants