You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-15466 Duplicated error message for type that doesn't conform to protocol
Issue Description:
When creating a type that conforms to Collection, create implementations for all requirements except for `subscript(bounds: Range<Index>) -> Subsequence`. This will cause the compiler to try to satisfy this requirement with an unavailable subscript, which will raise the following error:
It is unlikely that the user knows about this default implementation that is no longer available, and the error doesn't point to that implementation (which, in this case, contains a comment describing why it's no longer available).
Saying the unavailable subscript "was used to satisfy a requirement" makes it seem as if a user's subscript was used to satisfy the requirement, when in fact this refers to a subscript in the compiler (that the user likely doesn't know about).
The notes don't show up in Xcode, and by only reading the error message it's unclear which required subscript is the problem. For instance, Collection requires implementing both `subscript(position: Int) -> Element` and `subscript(bounds: Range<Index>) -> SubSequence`, both of which match the 'subscript(_🙂' signature in the error message.
This error could be improved if it read something like: “*default implementation of 'Collection' requirement 'subscript(*🙂' of type '(Range<Self.Index>) -> Self.SubSequence' is marked unavailable; did you mean to implement your own?_”. This message makes it clear that the error refers to a default implementation; that the problem is in the "Range" subscript; and that the user can implement their own subscript to solve it.
It would also be useful to add a fix-it to help the user add their own implementation.
The attached test.swift file causes these errors in Swift 5.5.1.
The text was updated successfully, but these errors were encountered:
Sorry for attaching 2 images of emoji to this bug report. I was reading it and my mouse dragged on it and caused it to be uploaded as attachment twice. I tried to delete them, but somehow can't.
Attachment: Download
Environment
MacOS 12.0.1 - Swift 5.5.1
Additional Detail from JIRA
md5: b7664ab271752893116e32098a0c909a
relates to:
Issue Description:
When creating a type that conforms to Collection, create implementations for all requirements except for `subscript(bounds: Range<Index>) -> Subsequence`. This will cause the compiler to try to satisfy this requirement with an unavailable subscript, which will raise the following error:
This error has the following problems:
It is unlikely that the user knows about this default implementation that is no longer available, and the error doesn't point to that implementation (which, in this case, contains a comment describing why it's no longer available).
Saying the unavailable subscript "was used to satisfy a requirement" makes it seem as if a user's subscript was used to satisfy the requirement, when in fact this refers to a subscript in the compiler (that the user likely doesn't know about).
The notes don't show up in Xcode, and by only reading the error message it's unclear which required subscript is the problem. For instance, Collection requires implementing both `subscript(position: Int) -> Element` and `subscript(bounds: Range<Index>) -> SubSequence`, both of which match the 'subscript(_🙂' signature in the error message.
This error could be improved if it read something like: “*default implementation of 'Collection' requirement 'subscript(*🙂' of type '(Range<Self.Index>) -> Self.SubSequence' is marked unavailable; did you mean to implement your own?_”. This message makes it clear that the error refers to a default implementation; that the problem is in the "Range" subscript; and that the user can implement their own subscript to solve it.
It would also be useful to add a fix-it to help the user add their own implementation.
The attached test.swift file causes these errors in Swift 5.5.1.
The text was updated successfully, but these errors were encountered: