Skip to content

Bad diagnostic for argument type mismatch in return expr #74463

@AnthonyLatsis

Description

@AnthonyLatsis

Description

This is specific to tuples. The return expression type mismatch error message is shown instead of the argument type mismatch error message (cannot_convert_to_return_type vs. cannot_convert_argument_value).

Reproduction

func foo(_: (Int, Int)) -> String {}

func test() -> String {
  return foo((0, true))
}
222 | func test() -> String {
223 |   return foo((0, true))
    |              `- error: cannot convert return expression of type '(Int, Bool)' to return type '(Int, Int)' [cannot_convert_to_return_type]
224 | }

Expected behavior

error: cannot convert value of type '(Int, Bool)' to expected argument type '(Int, Int)'

Environment

Swift version 6.0-dev (LLVM c7c87ee42989d4b, Swift 8493312)

Additional information

Reduced from #46829.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsreturnFeature → statements: `return` statementsstatementsFeature: statementsswift 6.0tuplesFeature: tuplestype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions