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-5243] Useless diagnostic comparing enum with invalid case #47818

Closed
NachoSoto opened this issue Jun 16, 2017 · 3 comments
Closed

[SR-5243] Useless diagnostic comparing enum with invalid case #47818

NachoSoto opened this issue Jun 16, 2017 · 3 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 type checker Area → compiler: Semantic analysis

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-5243
Radar rdar://problem/33914558
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.43 clang-900.0.22.8)

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

md5: bb6c106d6fe43d0ea3e4787ed8cfc35b

Issue Description:

enum E {
    case e1
}

let a: [E] = []

let x = E.e1 == .e2
let x: Bool = E.e1 == .e2
a.filter { $0 == .e2 }

I first discovered it with the closure case, but I was surprised to see that it fails to produce anything useful even with the explicit Bool annotation. In all these 3 cases the error you get is:

error: binary operator '==' cannot be applied to operands of type 'E' and '_'
note: expected an argument list of type '(Self, Self)'

This produces an even worse one:

_ = E.e1 == .e2
error: repl.swift:4:10: error: type of expression is ambiguous without more context
_ = E.e1 == .e2
    ~~~~~^~~~~~
@belkadan
Copy link
Contributor

cc @xedin

@slavapestov
Copy link
Member

@swift-ci create

@xedin
Copy link
Member

xedin commented Feb 5, 2020

Looks like all three cases now produce a correct diagnostic - `type 'E' has no member 'e2'`. Please verify using either master or 5.2 nightly snapshot.

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

No branches or pull requests

4 participants