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-5184] Confusing diagnostics with an escaping closure #47760

Open
swift-ci opened this issue Jun 10, 2017 · 2 comments
Open

[SR-5184] Confusing diagnostics with an escaping closure #47760

swift-ci opened this issue Jun 10, 2017 · 2 comments
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

@swift-ci
Copy link
Collaborator

Previous ID SR-5184
Radar rdar://32711708
Original Reporter vytis (JIRA User)
Type Bug
Environment

Xcode 9.0 beta (9M136h) with default Swift toolchain

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

md5: cec240dd4da017b9119a7c2b4a41bcbe

is duplicated by:

  • SR-8499 Useless error message without @escaping when closure types conversion is failed

Issue Description:

Having a closure in a tuple produces a confusing diagnostic message on assignment.

Example:

typealias ObserverCallback = () -> ()
typealias Observer = (limit: Int, callback: ObserverCallback)

var observer: Observer?

func addObserver(limit: Int, callback: ObserverCallback) {
    observer = (limit: limit, callback: callback)
}

Produces the diagnostic:

error: Circlone.playground:5:16: error: cannot assign value of type '(limit: Int, callback: () -> ())' to type 'Observer?' (aka 'Optional<(limit: Int, callback: () -> ())>')
    observer = (limit: limit, callback: callback)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  as! Observer

When the actual reason is that we need to add `@escaping` to a closure parameter:

func addObserver(limit: Int, callback: @escaping ObserverCallback) 
@belkadan
Copy link
Contributor

cc @milseman, @xedin

@milseman
Copy link
Mannequin

milseman mannequin commented Jun 12, 2017

Likely related to SR-2657

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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

2 participants