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-6677] Compiler error is unhelpful when incorrect type passed to argument that uses associated type in generic function #49226

Open
swift-ci opened this issue Dec 29, 2017 · 2 comments
Assignees
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-6677
Radar None
Original Reporter marcpalmer (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 9.2 GM.

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @xedin
Priority Medium

md5: 4bfd3c5445482a453c99c526b44b5b23

Issue Description:

See attached code. If you use a generic function with a type T that has an associated type U, and the function uses T.U as an argument type, passing the wrong type for that argument yields confusing errors.

Given a function declared something like:

    static func perform<T>(actionBinding: ActionBinding<T>, with state: T.ContextType?) -> Request<T> {
     // ...
    }

If you pass the wrong type of value for state you get errors of the form:

error: cannot convert value of type 'ActionBinding<SelectContentAction>' to expected argument type 'ActionBinding<_>'
action: AppFeatures.remoteControl.addToMix.selectContentAction, with: "Test", using: self, completion: { })

...where you would hope it would say something like "argument `with` expects a value of type X, but is passed a String".

The attached playground demonstrates this senario in isolation, about 40 lines.

@swift-ci
Copy link
Collaborator Author

Comment by Marc Palmer (JIRA)

I'm not sure if this is a variant of SR-708 - I am not skilled enough to tell if this is a truly different scenario.

@belkadan
Copy link
Contributor

belkadan commented Jan 2, 2018

cc @xedin, @rudkx

@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