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-3423] Enum with tuple raw value not allowed? #46011

Open
swift-ci opened this issue Dec 15, 2016 · 1 comment
Open

[SR-3423] Enum with tuple raw value not allowed? #46011

swift-ci opened this issue Dec 15, 2016 · 1 comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3423
Radar rdar://problem/28249531
Original Reporter chung (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: e69fffd31407e0ea9ed08f51b431c806

Issue Description:

Please see this question on SO: http://stackoverflow.com/questions/26387275/enum-of-tuples-in-swift

The OP was trying to do something like this:

enum ErrorCode: (Int, String) {
    case Generic_Error = (0, "Unknown")
    case DB_Error = (909, "Database")
}

Looks perfectly reasonable, but won't compile.

@swift-ci
Copy link
Collaborator Author

Comment by Raphael (JIRA)

If we do typealias A = (Int, String) and ErrorCode: A we get past the syntax error and get:

raw type 'A' (aka '(Int, String)') is not expressible by any literal

That's just plain wrong; at least, I'd consider (1,"2") to be a literal.

But, of course, we don't only get one error but also this:

type 'ErrorCode' does not conform to protocol 'RawRepresentable'

which seems redundant.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal and removed new feature labels Nov 10, 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 feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

2 participants