[SR-12847] Function Builder with return statements produces confusing and erroneous diagnostic #55293
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
result builders
Feature: Result builders
Environment
Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
Additional Detail from JIRA
md5: 8b107381b04ea5bf82062c3cda810120
Issue Description:
The first that came to mind when I was struggling with this was this tweet: https://twitter.com/javi/status/1262381836614893568?s=21.
Consider this seemingly normal code:
This produces this error, with a bogus fixit:
The actual error is those `return` statements, but that's not intuitive at all, and the error doesn't help one bit.
The underlying issue is that function builders lead us to believe we're writing regular code with closures, but they're full of these paper cuts.
The text was updated successfully, but these errors were encountered: