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-4795] Useless diagnostic: "cannot convert value of type 'A' to expected argument type '_OptionalNilComparisonType'" #47372

Closed
NachoSoto opened this issue May 3, 2017 · 4 comments
Assignees
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

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-4795
Radar rdar://problem/33914446
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment
  • Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)

  • Swift version 4.0 (swiftlang-900.0.59 clang-900.0.34.2)

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

md5: 78762227283443b6be314c66dc4da4b8

Issue Description:

This code:

enum A {
    case a(Int)
    case b(Bool)
}

let a: A? = nil
let b: A = .b(true)

a == b  
a != b

Produces:

error: repl.swift:7:6: error: cannot convert value of type 'A' to expected argument type '_OptionalNilComparisonType'
a == b
     ^
error: repl.swift:7:6: error: cannot convert value of type 'A' to expected argument type '_OptionalNilComparisonType'
a != b
     ^

Instead of pointing out that A does not implement Equatable.

This is similar to SR-4318. In both cases Swift can't produce the actually helpful diagnostic pointing out that the type doesn't implement Equatable.

@NachoSoto
Copy link
Contributor Author

Still an issue in Swift 4.0

@slavapestov
Copy link
Member

@swift-ci create

@xedin
Copy link
Member

xedin commented Sep 16, 2019

Resolved by #27063 Please use the next available snapshot of master to verify.

@NachoSoto
Copy link
Contributor Author

That’s amazing, looks like a huge improvement. Unfortunately in the 2 and a half years since I posted this, I changed careers and I’m no longer a full-time software developer.

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

No branches or pull requests

3 participants