Skip to content

[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

@YOCKOW

Description

@YOCKOW
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'.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions