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-1263] Compiler wrongfully complains of illegal syntax when declaring multiple conformances for a protocol's associated type. #43871

Closed
swift-ci opened this issue Apr 19, 2016 · 6 comments
Assignees
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1263
Radar None
Original Reporter Vatsal Manot (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Environment

Xcode 7.3, Swift 2.2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, Parser, StarterBug
Assignee @slavapestov
Priority Medium

md5: a77e8115a872254919c357ee734646ef

Issue Description:

The following code is legal:

{code:swift }

protocol A
{

}

protocol B
{

}

typealias C_AssociatedTypeA_Inheritance = protocol<A, B>

protocol C
{
associatedtype AssociatedTypeA: C_AssociatedTypeA_Inheritance
}

While this is not:

{code:swift}

protocol A
{
    
}

protocol B
{
    
}

protocol C
{
    associatedtype AssociatedTypeA: protocol<A, B>
}

EDIT: I had assumed that this was just a bug, but according to the comments this is intended to be illegal. However, I feel that we should allow this syntax. I've corrected the 'Issue Type' to 'Improvement'.

@belkadan
Copy link
Contributor

That syntax is illegal. Are you saying it should be legal? Certainly we could improve the diagnostic to suggest the correct syntax.

@swift-ci
Copy link
Collaborator Author

Comment by Vatsal Manot (JIRA)

Hi @belkadan, thanks for letting me know. At first, I was unsure about the nature of this issue, but I'll update the text now that that's cleared up. And yes, I'm saying that it should be legal.

@modocache
Copy link
Mannequin

modocache mannequin commented Dec 10, 2016

This is labeled "Parser" "StarterBug." Should the parser be modified such that it allows this syntax? Or is that something that would need to be discussed on swift-evolution?

If this requires a swift-evolution proposal, I suggest closing the issue until we can be certain it's a change that the Swift team is willing to make.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Dec 13, 2016

The right syntax here is associatedtype AssociatedTypeA: A, B
Because this is type-inheritance-clause, and that only allows comma-separated type-identifier­.

I believe we have already improved the diagnostics for this case:

    associatedtype AB: protocol<A, B> // error: protocol composition is neither allowed nor needed here
                                      // (with fix-it replacing 'protocol<A, B>' with 'A, B')

But, using the new protocol composition syntax A & B lacks the fix-it.

@modocache
Copy link
Mannequin

modocache mannequin commented Dec 16, 2016

@rintaro, sounds like the TODO you linked to deserves its own report, and this report should be closed as "invalid" or "wontfix". Assigning to @belkadan to close or decide otherwise. 🙂

@slavapestov
Copy link
Member

On master we now allow both 'associatedtype T : A, B' and 'associatedtype T : A & B'.

@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
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

3 participants