[SR-5455] Compiler not able to provide automatic fix-it for returning closure #48027
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
Xcode Version 9.0 beta 3 (9M174d) on macOS Version 10.12.5 (16F73)
Additional Detail from JIRA
md5: 0a98c7b07e7ad0568d85805fd24092d5
duplicates:
Issue Description:
The compiler is not providing automatic fix-it suggestions for returning closures that are not properly labeled with a `@escaping` keyword.
For example, here is an incorrect version of a function that requires two `@escaping` keywords to be inserted.
Despite the complexity, the compiler manages to catch two errors but fails to provide a fix-it for the latter.
1. Closure use of non-escaping parameter `f` may allow it to escape
a. Automatic Fix-it by doing `f: @escaping (A) - > (B)`
2. Closure use of non-escaping parameter `reducer` may allow it to escape
b. No Fix-it provided
As you see above, the two places where a compile-time error occurred had the same exact problem; they both needed a `@escaping`. However, while the function parameter was offered an automatic fix-it, the nested closure being returned was not.
Here’s the correct version of the function.
The text was updated successfully, but these errors were encountered: