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-13226] "type of expression is ambiguous" instead of specific error, when using generic constraints in initializer #55666

Closed
marcrasi mannequin opened this issue Jul 15, 2020 · 2 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

@marcrasi
Copy link
Mannequin

marcrasi mannequin commented Jul 15, 2020

Previous ID SR-13226
Radar None
Original Reporter @marcrasi
Type Bug
Status Closed
Resolution Done
Environment

swift-DEVELOPMENT-SNAPSHOT-2020-07-14-a-ubuntu20.04

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

md5: 173002612707405fa76f06a111ba223a

Issue Description:

struct W<T> {}

struct S<C1: Collection> {
  init<C2>(_ c2: W<C2>) where C2: Collection, C1.Element == W<C2.Element> {
    fatalError("implementation not relevant to bug report")
  }
}

let _ = S<[W<String>]>(W<[Int]>())

// Actual diagnostic:
//   error: type of expression is ambiguous without more context
//   let _ = S<[W<String>]>(W<[Int]>())
//           ^~~~~~~~~~~~~~~~~~~~~~~~~

// Desired diagnostic: anything informative about the type mismatch. Maybe:
//   error: initializer requires "W<String>" and "W<Int>" to be equivalent
//   let _ = S<[W<String>]>(W<[Int]>())
//           ^
//
//   note: where C1 == [W<String>] and C2 == [Int]
//   init<C2>(_ c2: W<C2>) where C2: Collection, C1.Element == W<C2.Element> {
//   ^
@LucianoPAlmeida
Copy link
Collaborator

Fixed on master @marcrasi
Can you please verify and close? Thanks

@marcrasi
Copy link
Mannequin Author

marcrasi mannequin commented Aug 14, 2020

I verified it. Thanks!!

@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

1 participant