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-11453] Unhelpful error message when equating an optional enum that does not conform to Equatable #53854

Open
swift-ci opened this issue Sep 11, 2019 · 1 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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11453
Radar None
Original Reporter apaszke (JIRA User)
Type Bug
Environment

Apple Swift version 5.1 (swiftlang-1100.0.257.2 clang-1100.0.31.3)

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

md5: 8a3854ab7fb3ac4be15e8e76981b5840

Issue Description:

The following code is incorrect, because `E` does not explicitly declare a conformance to `Equatable`:

enum E {
    case a(Int)
    case b(String)
}

var lookup: [Int: E] = [:]
guard lookup[0] == .unknown else { fatalError() }

However, the error message emitted by `swiftc` is the following, which does not really help in finding the root cause:

error.swift:7:21: error: type 'E?' has no member 'unknown'
guard lookup[0] == .unknown else { fatalError() }
                   ~^~~~~~~
@belkadan
Copy link
Contributor

cc @hborla, @xedin

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants