-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-4172] () == () doesn't compile #46755
Comments
Comment by Arjun Nayini (JIRA) Eridius (JIRA User) - Brand new to the Swift project and saw this bug as potentially a good task. Was thinking about adding a generated 0-ary `==` implementation to resolve this problem. Seems to work fine in a Playground. Can I self-assign this and complete it or is there typically an approval process where this is marked as a bug by the core team before someone can self-assign. |
anayini (JIRA User) There's no official approval process for bug tickets. You should be able to self-assign and submit a PR. |
What's the use case for this? If it's highly marginal/just for consistency, it may not be worth increasing the size of the std lib just for this case, whereas it's fine if there's a way in which this neatens up some likely code. |
Comment by Arjun Nayini (JIRA) @airspeedswift - I'm not the reporter, just grabbed the ticket since it seemed like an easy starter task to be honest. I agree that, especially after adding the `Comparable` operators, which I guess were out of scope of this bug, the diff has become sort of large. |
Hi Arjun – thanks so much for picking this up! It's definitely appreciated, whether or not we end up deciding to integrate. |
Why would you add comparable operators for |
Comment by Arjun Nayini (JIRA) Eridius (JIRA User) - Original PR I put up actually only added `==`, but sounds like people wanted the rest of the operators as well. Maybe at least `==` and `!=` make sense? If we can agree that the `Comparable` operators don't make sense, the PR becomes a small addition to the file (1 or 2 functions depending on if we want to include `!=`) |
In any case, the code that motivated this ticket looked like #if os(iOS) || os(OSX) || os(watchOS) || os(tvOS)
import struct Foundation.Decimal
#else
// A placeholder used for platforms that don't support `Decimal`.
public typealias DecimalPlaceholder = ()
#endif
public enum Foo {
// ...
#if os(iOS) || os(OSX) || os(watchOS) || os(tvOS)
case decimal(Decimal)
#else
// A plceholder for decimal number support.
// We need this or else people can't write exhaustive switches against our
// enum in a cross-platform-compatible way.
case decimal(DecimalPlaceholder)
#endif
public static func ==(lhs: Foo, rhs: Foo) -> Bool {
switch (lhs, rhs) {
// ...
case let (.decimal(a), .decimal(b)): return a == b
}
}
} But of course this doesn't actually compile on Linux because |
anayini (JIRA User) I only care about |
Also, if you have a PR, can you please link it here? |
Comment by Arjun Nayini (JIRA) Ah yup - sorry - here it is: |
Comment by Arjun Nayini (JIRA) Fixed in #8354 |
Comment by Arjun Nayini (JIRA) Eridius (JIRA User) - This finally got in 🙂 |
Environment
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: b7c81b111f008dc786f236ab4d1c0698
Issue Description:
As the summary says,
() == ()
doesn't compile. This seems like an oversight, since tuples (up to 6-ary) support==
if they can (i.e. if all their elements areEquatable
), and there's no reason why the base case of the 0-ary tuple shouldn't.The text was updated successfully, but these errors were encountered: