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-14173] Referencing operator function '!=' on 'BinaryInteger' requires that enum with associated value conform to 'BinaryInteger' #56551

Open
idrougge opened this issue Feb 9, 2021 · 3 comments
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 type checker Area → compiler: Semantic analysis

Comments

@idrougge
Copy link

idrougge commented Feb 9, 2021

Previous ID SR-14173
Radar rdar://problem/74149099
Original Reporter @idrougge
Type Bug
Environment

Version 12.3 (12C33)

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

md5: e6ecba6fdfe08bae56e4fc622a8187eb

Issue Description:

Given an enum, where one case has an associated value:

enum E {
 case a
 case b(Double)
 case c
}

When doing a comparison of a value v: E, as below:

if v != .c { … }

the compiler puts out this error message:

Referencing operator function '!=' on 'BinaryInteger' requires that 'E' conform to 'BinaryInteger'.

This error message is misleading since at no point is any reference to BinaryInteger or its ![](= made, the underlying error being that one of the enum cases has an associated value and that the )= operator needs to be implemented or synthesised by declaring Comparable conformance.

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Collaborator

Comment by Karthik (JIRA)

theindigamer (JIRA User)

From Swift 5.3 diagnostic message has been changed to
`error: binary operator '!=' cannot be applied to two 'E' operands`
**

*`note: binary operator '!=' cannot be synthesized for enums with associated values`
*

Should the message be updated?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@daveharig
Copy link

daveharig commented Jul 24, 2023

I get this error

"Referencing operator function '!=' on 'BinaryInteger' requires that 'MyEnum' conform to 'BinaryInteger'"

It has no mention of associated values.

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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants