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-8277] Inappropriate error message is viewed when a wrong parameter is passed to a function and its result is passed to another function. #50808

Closed
YOCKOW opened this issue Jul 17, 2018 · 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

@YOCKOW
Copy link
Collaborator

YOCKOW commented Jul 17, 2018

Previous ID SR-8277
Radar rdar://problem/29318186
Original Reporter @YOCKOW
Type Bug
Status Closed
Resolution Done
Environment
  • OS: macOS, Ubuntu 16.04

  • Swift: 4.1.2, 4.2-dev

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

md5: e5b307623cd85333674994be0dcf489a

Issue Description:

There are two error messages when the following code is compiled. But the second one does not indicate the true nature of the problem.

[Code]

func f(_:Bool) {}

struct S {
  func g(_:Int) -> Bool { return true }
  func g(_:Double) -> Bool { return false }
}

let s = S()
let string = "ABC"

s.g(string)
// -> error: cannot invoke 'g' with an argument list of type '(String)'
//    note: overloads for 'g' exist with these partially matching parameter lists: (Int), (Double)
// * Just as I expected.

f(s.g(string))
// -> error: 'g' produces 'Bool', not the expected contextual result type 'Bool'
// * Why isn't it the same as above? --- I believe, at least, 'Bool' is equal to 'Bool'.
@belkadan
Copy link
Contributor

cc @xedin

@xedin
Copy link
Member

xedin commented Jan 24, 2020

@YOCKOW Please try with the recent master snapshot to verify that we produce much better diagnostics now.

The compiler is going to produce following diagnostic in both cases `No exact matches in call to instance method 'g'` and point to each overload with description of what went wrong via a note.

@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Jan 26, 2020

@xedin
Thank you very much for resolving this issue.
I have confirmed that very intelligible messages were emitted in swift-DEVELOPMENT-SNAPSHOT-2020-01-24-a.

@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

3 participants