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-8776] Confusing error with broken CaseIterable conformance #51284

Open
lilyball mannequin opened this issue Sep 17, 2018 · 1 comment
Open

[SR-8776] Confusing error with broken CaseIterable conformance #51284

lilyball mannequin opened this issue Sep 17, 2018 · 1 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

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Sep 17, 2018

Previous ID SR-8776
Radar None
Original Reporter @lilyball
Type Bug
Environment

Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Target: x86_64-apple-darwin17.7.0

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

md5: a6ba5ec9b7e3fa45b28fea7ca3c1c0d9

is duplicated by:

  • SR-9582 Change "can derive conformances" condition for CaseIterable

relates to:

  • SR-8777 CaseIterable synthesis should work in the presence of a manual AllCases typealias
  • SR-9582 Change "can derive conformances" condition for CaseIterable

Issue Description:

If I try and declare an enum that wants to synthesize CaseIterable conformance but I break that by declaring the AllCases typealias myself, I get a confusing error when I try and access the allCases property.

enum Foo: CaseIterable {
    typealias AllCases = Set<Foo>
    case one, two, three
}
dump(Foo.allCases)

produces

<unknown>:0: error: 'allCases' is inaccessible due to 'internal' protection level
<unknown>:0: note: 'allCases' declared here
unnamed.swift:1:6: error: type 'Foo' does not conform to protocol 'CaseIterable'
enum Foo: CaseIterable {
     ^
unnamed.swift:1:6: error: protocol 'CaseIterable' is broken; cannot derive conformance for type 'Foo'
enum Foo: CaseIterable {
     ^

If I mark the enum as public instead, then the first error becomes the even more broken

<unknown>:0: error: 'allCases' is inaccessible due to '<<ERROR>>' protection level
@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Sep 18, 2018

Also see SR-8777 wherein I argue that the above code snippet should actually work.

@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
Projects
None yet
Development

No branches or pull requests

0 participants