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-12438] Poor diagnostic for unapplied operator reference to == #54877

Open
hamishknight opened this issue Mar 27, 2020 · 4 comments
Open

[SR-12438] Poor diagnostic for unapplied operator reference to == #54877

hamishknight opened this issue Mar 27, 2020 · 4 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

@hamishknight
Copy link
Collaborator

Previous ID SR-12438
Radar rdar://problem/62201038
Original Reporter @hamishknight
Type Bug
Environment

Swift version 5.3-dev (LLVM d59da0c, Swift 5af04d3)
Target: x86_64-apple-darwin18.5.0

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

md5: 1cd198317940a717c3181c549aee79a2

Issue Description:

The following produces a poor diagnostic:

func foo<T>(_ a: T, _ op: ((T, T) -> Bool)) {}
func bar(_ e: Error) {
  foo(e, ==) // error: type of expression is ambiguous without more context
}

The problem is we can end up with a mix of argument mismatch fixes for the first argument, in addition to conformance fixes for the second argument. The argument mismatch fixes make sense in isolation (when we're binding concrete overloads of ==), but we need to find a sensible way of preferring the Equatable conformance mismatch fix in this case such that we complain about Error not being Equatable.

@LucianoPAlmeida
Copy link
Collaborator

Hey @hamishknight 🙂
Increase the impact on Equatable conformance mismatch fix could be a way to do this?

@hamishknight
Copy link
Collaborator Author

Hi @LucianoPAlmeida! Adjusting the impacts could help (though you'd want to decrease the conformance mismatch fix impact), but I think we'll probably need a more general solution to this problem. From the discussion with Pavel on #30686 (comment) I think we'll want to try and detect this in diagnoseAmbiguityWithFixes and emit a general "operator cannot be applied with X operands" diagnostic for now.

@LucianoPAlmeida
Copy link
Collaborator

Humm, makes sense thank you @hamishknight 🙂
I remember there were some cases when just tweaking impact was enough, so I was jsut curious if this may apply here too.

@beccadax
Copy link
Contributor

@swift-ci create

@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

3 participants