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-6840] Confusing error in conditional conformance #49389

Open
natecook1000 opened this issue Jan 25, 2018 · 2 comments
Open

[SR-6840] Confusing error in conditional conformance #49389

natecook1000 opened this issue Jan 25, 2018 · 2 comments
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement

Comments

@natecook1000
Copy link
Member

Previous ID SR-6840
Radar None
Original Reporter @natecook1000
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI
Assignee None
Priority Medium

md5: ad232fab3c01c12aad235f16cc7f120e

relates to:

  • SR-6474 Conditional conformance to refined protocol inappropriately fails

Issue Description:

This code rightly doesn't compile, but while the error messages are all correct, they are confusing:

protocol P {}
protocol Q : P {}
protocol R : P {}

struct X<T> {}
extension X: P where T: Q {}
extension X: Q where T: Q {}
extension X: R where T: R {}

The issue there is that extension X: R where T: R leaves out conformance to P, because the conformance to P is constrained to T: Q instead of just T. These are the errors I get:

confusing_error.swift:8:1: error: type 'T' does not conform to protocol 'Q'
extension X: R where T: R {}
^
confusing_error.swift:8:1: error: 'R' requires that 'T' conform to 'Q'
extension X: R where T: R {}
^
confusing_error.swift:8:1: note: requirement specified as 'T' : 'Q'
extension X: R where T: R {}
^
confusing_error.swift:8:1: note: requirement from conditional conformance of 'X<T>' to 'P'
extension X: R where T: R {}
^

I don't know how possible it is to improve this, but I think the errors would be more clear if they said something like this:

error: Type `X<T>` doesn't conform to inherited protocol `P` with the requirement `T` : `R`
extension X: R where T: R {}
error Type `X<T> : P` requirement specified as `T` : `Q`
extension X: P where T: Q {}
@belkadan
Copy link
Contributor

cc @DougGregor

@DougGregor
Copy link
Member

Also cc @huonw

@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
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement
Projects
None yet
Development

No branches or pull requests

3 participants