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-9925] Void is not equatable (enum cases with Void associated values can't auto-synthesise Equatable) #52331

Open
weissi opened this issue Feb 14, 2019 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@weissi
Copy link
Member

weissi commented Feb 14, 2019

Previous ID SR-9925
Radar None
Original Reporter @weissi
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: f24223391d22830b4a28a7f77de8add5

relates to:

  • SR-1222 A tuple of Equatable types should be Equatable

Issue Description:

this Swift program should work

enum Foo: Equatable { case x(()) }

but

$ swift /tmp/test.swift
/tmp/test.swift:1:6: error: type 'Foo' does not conform to protocol 'Equatable'
enum Foo: Equatable { case x(()) }
     ^
Swift.==:1:24: note: candidate would match if 'Foo' conformed to 'RawRepresentable'
@inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable
                       ^
Swift.FloatingPoint:2:24: note: candidate would match if 'Foo' conformed to 'FloatingPoint'
    public static func == (lhs: Self, rhs: Self) -> Bool
                       ^
Swift.BinaryInteger:2:24: note: candidate would match if 'Foo' conformed to 'BinaryInteger'
    public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger
                       ^
Swift._Pointer:2:24: note: candidate would match if 'Foo' conformed to '_Pointer'
    public static func == (lhs: Self, rhs: Self) -> Bool
                       ^
Swift.Strideable:3:35: note: candidate would match if 'Foo' conformed to 'Strideable'
    @inlinable public static func == (x: Self, y: Self) -> Bool
                                  ^
Swift.StringProtocol:2:35: note: candidate would match if 'Foo' conformed to 'StringProtocol'
    @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol
                                  ^
Swift.SIMD:4:24: note: candidate would match if 'Foo' conformed to 'SIMD'
    public static func == (lhs: Self, rhs: Self) -> Bool
                       ^
Swift.Equatable:2:17: note: protocol requires function '==' with type '(Foo, Foo) -> Bool'; do you want to add a stub?
    static func == (lhs: Self, rhs: Self) -> Bool
                ^

problem is that Void isn't Equatable

  1> func f<E: Equatable>(_ x: E) {}
  2> f(())
error: repl.swift:2:3: error: argument type '()' does not conform to expected type 'Equatable'
f(())
  ^
@belkadan
Copy link
Contributor

Degenerate case of SR-1222 (tuples of Equatable should be Equatable)

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

No branches or pull requests

2 participants