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-3198] Misleading compiler error when defining comparison operator with wrong return type #45786

Closed
swift-ci opened this issue Nov 13, 2016 · 2 comments
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3198
Radar None
Original Reporter Karaberov (JIRA User)
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI
Assignee None
Priority Medium

md5: 7016a96416c4c42971331efed97ee627

duplicates:

  • SR-2208 Binary operator '/' cannot be applied to two 'Int' operands

Issue Description:

Tested on Xcode 8.1, Swift 3.0.1

When we implement custom comparison operator and either forgot to specify valid return type like this:

public func == (rhs: [[Int]], lhs: [[Int]])
 {
   return rhs.count == lhs.count
}

or specified wrong return type like this:

public func == (rhs: [[Int]], lhs: [[Int]]) -> DarwinBoolean
 {
   return rhs.count == lhs.count
}

we got
Binary operator '==' cannot be applied to two 'Int' operands
instead of expected
'==' produces 'Bool', not the expected contextual result type 'DarwinBoolean'.

When I use usual function I got an expected compiler error.

@belkadan
Copy link
Contributor

This was fixed in master. @rudkx, @xedin, do you know which bug to dup it to?

@rudkx
Copy link
Member

rudkx commented Nov 14, 2016

Looks like SR-2208.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 diagnostics QoI Bug: Diagnostics Quality of Implementation improvement
Projects
None yet
Development

No branches or pull requests

3 participants