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-2167] Segfault when extending C-enum with Hashable w/o implementing hashValue #44775
Comments
I think we already try to make them Hashable, which means we should just reject the conformance. |
Comment by Paul Styrnol (JIRA) Can you explain what you mean by reject? Would the following work (as long as the enum doesn't have cases with arguments)?
By the way, the more testing I do the stranger it gets: In Xcode Xcode 7.3.1, Swift 2.2 either of the following extensions compiles as long it stands alone:
In both environments I can remove Hashable as a supertype for my protocol as long as usage is limited to generic constraints in functions/methods:
|
Comment by Paul Styrnol (JIRA) I added some more information about the workaround for the segfaults in the description. Let me know if any of this should go into a separate issue. |
I believe they're all already Hashable upon import.
|
Comment by Paul Styrnol (JIRA) Consider the following usecase:
The Foo variant already works with Swift enums. |
Oh, yes, it's definitely a bug. I'm just pointing out that you shouldn't be able to extend a C enum with Hashable itself, just things that derive from Hashable. |
Has this bug, and any related bugs demonstrated in this report, fixed? If so, then this report should be closed. |
Environment
Xcode 8 beta 3, Swift 3
Xcode 7.3.1, Swift 2.2
Additional Detail from JIRA
md5: ad951f6ea9f3f654bd2860351c7c4bb8
is duplicated by:
Issue Description:
I stumbled upon this when I wanted to use enums adopting a protocol as dictionary keys w/o having using the enum type in the type declaration (e.g. [FooProtocolAdoptedByEnum: Any]). This is where the unintended workaround of subtyping Hashable and using the enum type as keys comes from. It works for real Swift enums but not for C-enums.
Edit:
The workaround variant compiles but there are issues when using the enum type in a different file:
FileA.swift:
FileB.swift
Link error:
In a large project I am working on I also get a link error about a duplicate symbol (__TFE21MyModuleNameOSC18AVCaptureFlashModeg9hashValueSi) in two files, but I am unable to repro this in a test project.
The text was updated successfully, but these errors were encountered: