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-11387] Misleading error message with ambiguous let statement #53788

Closed
swift-ci opened this issue Aug 28, 2019 · 5 comments
Closed

[SR-11387] Misleading error message with ambiguous let statement #53788

swift-ci opened this issue Aug 28, 2019 · 5 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

@swift-ci
Copy link
Collaborator

Previous ID SR-11387
Radar None
Original Reporter apaszke (JIRA User)
Type Bug
Status Closed
Resolution Done
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: e924a38185ed9bc492289cae8c7588a0

Issue Description:

Consider this small snippet:

public enum X: Equatable {
  case x([Int])
  case y(Int)
}

func test(_ x: X) {
  switch x {
  case let .x(vars):
    let constr = .y(vars.count)
  default: break
  }
}

The issue here is that .y is not qualified with X, so it ends up being ambiguous, but the reported error is:

error.swift:9:21: error: ambiguous reference to member 'count'
    let constr = .y(vars.count)
                    ^~~~
Swift.Array<τ_0_0>:18:27: note: found this candidate
    @inlinable public var count: Int { get }
                          ^
Swift.Collection:5:27: note: found this candidate
    @inlinable public var count: Int { get }
                          ^

Which is false and quite confusing.

@belkadan
Copy link
Contributor

cc @xedin, @hborla

@LucianoPAlmeida
Copy link
Collaborator

This seems fixed on 5.2 that's the actual diagnostic

  let constr = .y(vars.count) // error produced: reference to member 'y' cannot be resolved without a contextual type

apaszke (JIRA User) Can you verify on Xcode 11.4 and close 🙂

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 8, 2020

Comment by Adam Paszke (JIRA)

I don't have my Mac anymore, so it will be hard for me to verify this, but please do close the issue if you think it's been resolved.

@LucianoPAlmeida
Copy link
Collaborator

cc @xedin

@xedin
Copy link
Member

xedin commented Apr 27, 2020

Verified with 11.4 for apaszke (JIRA User), going to close. Thank you, @LucianoPAlmeida!

@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