[SR-9312] Confusing error when indirectly returning in map #51782
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
Environment
version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Additional Detail from JIRA
md5: a5be35bd52850917462d3f2f05995f74
Issue Description:
When mapping over a value that is a tuple, indirectly returning it will create a confusing / incorrect error.
Imagine the following code:
The following error appears on line 2:
Using the fixit, we will then get this code, that produces the actual, expected error... and another, less expected one:
The second error is unexpected.
Both can be fixed by explicitly using a return type:
... but we could've done that in the first place, using destructuring:
The text was updated successfully, but these errors were encountered: